示例#1
0
const char *
XDefaultString(void)
{
    XLCd lcd = _XlcCurrentLC();

    if (lcd == NULL)
	return (char *) NULL;

    return (*lcd->methods->default_string)(lcd);
}
示例#2
0
void
XwcFreeStringList(
    wchar_t **list)
{
    XLCd lcd = _XlcCurrentLC();

    if (lcd == NULL)
	return;

    (*lcd->methods->wc_free_string_list)(lcd, list);
}
示例#3
0
int
Xutf8TextPropertyToTextList(
    Display *dpy,
    const XTextProperty *text_prop,
    char ***list_ret,
    int *count_ret)
{
    XLCd lcd = _XlcCurrentLC();

    if (lcd == NULL)
	return XLocaleNotSupported;

    return (*lcd->methods->utf8_text_prop_to_list)(lcd, dpy, text_prop,
						   list_ret, count_ret);
}
示例#4
0
int
Xutf8TextListToTextProperty(
    Display *dpy,
    char **list,
    int count,
    XICCEncodingStyle style,
    XTextProperty *text_prop)
{
    XLCd lcd = _XlcCurrentLC();

    if (lcd == NULL)
	return XLocaleNotSupported;

    return (*lcd->methods->utf8_text_list_to_prop)(lcd, dpy, list, count,
						   style, text_prop);
}
示例#5
0
char	*
_XkbGetCharset(void)
{
    char *tmp;
    XLCd lcd;

    tmp = getenv( "_XKB_CHARSET" );
    if ( tmp )
	return tmp;

    lcd = _XlcCurrentLC();
    if ( lcd )
	return XLC_PUBLIC(lcd,encoding_name);

    return NULL;
}
示例#6
0
int
_Xlcmbtowc(
    XLCd lcd,
    wchar_t *wstr,
    char *str,
    int len)
{
    static XLCd last_lcd = NULL;
    static XlcConv conv = NULL;
    XPointer from, to;
    int from_left, to_left;
    wchar_t tmp_wc;

    if (lcd == NULL) {
	lcd = _XlcCurrentLC();
	if (lcd == NULL)
	    return -1;
    }
    if (str == NULL)
	return XLC_PUBLIC(lcd, is_state_depend);

    if (conv && lcd != last_lcd) {
	_XlcCloseConverter(conv);
	conv = NULL;
    }

    last_lcd = lcd;

    if (conv == NULL) {
	conv = _XlcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar);
	if (conv == NULL)
	    return -1;
    }

    from = (XPointer) str;
    from_left = len;
    to = (XPointer) (wstr ? wstr : &tmp_wc);
    to_left = 1;

    if (_XlcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0)
	return -1;

    return (len - from_left);
}
示例#7
0
int
_Xlcwctomb(
    XLCd lcd,
    char *str,
    wchar_t wc)
{
    static XLCd last_lcd = NULL;
    static XlcConv conv = NULL;
    XPointer from, to;
    int from_left, to_left, length;

    if (lcd == NULL) {
	lcd = _XlcCurrentLC();
	if (lcd == NULL)
	    return -1;
    }
    if (str == NULL)
	return XLC_PUBLIC(lcd, is_state_depend);

    if (conv && lcd != last_lcd) {
	_XlcCloseConverter(conv);
	conv = NULL;
    }

    last_lcd = lcd;

    if (conv == NULL) {
	conv = _XlcOpenConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte);
	if (conv == NULL)
	    return -1;
    }

    from = (XPointer) &wc;
    from_left = 1;
    to = (XPointer) str;
    length = to_left = XLC_PUBLIC(lcd, mb_cur_max);

    if (_XlcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0)
	return -1;

    return (length - to_left);
}
示例#8
0
char *
XSetLocaleModifiers(
    const char *modifiers)
{
    XLCd lcd = _XlcCurrentLC();
    char *user_mods;
    char *mapped_mods;

    if (!lcd)
	return (char *) NULL;
    if (!modifiers)
	return lcd->core->modifiers;
    user_mods = getenv("XMODIFIERS");
    mapped_mods = (*lcd->methods->map_modifiers) (lcd, user_mods, modifiers);
    if (mapped_mods) {
	Xfree(lcd->core->modifiers);
	lcd->core->modifiers = mapped_mods;
    }
    return mapped_mods;
}
示例#9
0
int
_Xlcmbstoutf8(
    XLCd lcd,
    char *ustr,
    const char *str,
    int len)
{
    XlcConv conv;
    XPointer from, to;
    int from_left, to_left, ret;

    if (lcd == NULL) {
	lcd = _XlcCurrentLC();
	if (lcd == NULL)
	    return -1;
    }

    conv = _XlcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNUtf8String);
    if (conv == NULL)
	return -1;

    from = (XPointer) str;
    from_left = strlen(str);
    to = (XPointer) ustr;
    to_left = len;

    if (_XlcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0)
	ret = -1;
    else {
	ret = len - to_left;
	if (ustr && to_left > 0)
	    ustr[ret] = '\0';
    }

    _XlcCloseConverter(conv);

    return ret;
}
示例#10
0
int
_Xlcwcstombs(
    XLCd lcd,
    char *str,
    wchar_t *wstr,
    int len)
{
    XlcConv conv;
    XPointer from, to;
    int from_left, to_left, ret;

    if (lcd == NULL) {
	lcd = _XlcCurrentLC();
	if (lcd == NULL)
	    return -1;
    }

    conv = _XlcOpenConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte);
    if (conv == NULL)
	return -1;

    from = (XPointer) wstr;
    from_left = _Xwcslen(wstr);
    to = (XPointer) str;
    to_left = len;

    if (_XlcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0)
	ret = -1;
    else {
	ret = len - to_left;
	if (str && to_left > 0)
	    str[ret] = '\0';
    }

    _XlcCloseConverter(conv);

    return ret;
}
示例#11
0
Bool
XSupportsLocale(void)
{
    return _XlcCurrentLC() != (XLCd)NULL;
}