2 /* Copyright (C) 2002 Olivier Chapuis */
3 /* This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 /* ---------------------------- included header files ---------------------- */
24 #include <X11/Xatom.h>
29 #include "FlocaleCharset.h"
32 #if FlocaleLibcharsetSupport
33 #include <libcharset.h>
35 #if FlocaleCodesetSupport
39 /* ---------------------------- local definitions -------------------------- */
41 /* ---------------------------- local macros ------------------------------- */
43 /* ---------------------------- imports ------------------------------------ */
45 /* ---------------------------- included code files ------------------------ */
47 /* ---------------------------- local types -------------------------------- */
49 /* ---------------------------- forward declarations ----------------------- */
51 /* ---------------------------- local variables ---------------------------- */
53 /* X locale charset */
54 static FlocaleCharset
*FLCXOMCharset
= NULL
;
55 /* list of XOM locale charset */
56 static FlocaleCharset
**FLCXOMCharsetList
= NULL
;
57 static int FLCXOMCharsetList_num
= 0;
59 static FlocaleCharset
*FLCUtf8Charset
= NULL
;
60 /* locale charset from the locale not X */
61 static FlocaleCharset
*FLCLocaleCharset
= NULL
;
63 static char *nullsl
[] = {NULL
};
66 /* from hpux iconv man page: The fromcode and tocode names can be any length,
67 * but only the first four and the last letter are used to identify the code
69 /* the first name is the gnu canonical name */
70 char *armscii_8
[] = {"ARMSCII-8", NULL
};
71 char *big5_0
[] = {"BIG5",
72 "big5", /* aix, hpux, osf */
73 "zh_TW-big5", /* solaris 9? */
75 char *big5hkscs_0
[] = {"BIG5-HKSCS",
77 "big5", /* aix, hpux, osf */
78 "zh_TW-big5", /* solaris 9? */
80 char *cns11643
[] = {"EUCTW",
86 char *dosencoding_cp437
[] = {"CP437", NULL
};
87 char *dosencoding_cp850
[] = {"CP850",
91 char *gb2312_1980_0
[] = {"EUC-CN",
93 "gb2312", /* solaris */
96 "IBM-eucCN", /* aix */
99 char *gbk_0
[] = {"GBK", NULL
};
100 char *georgian_academy
[] = {"GEORGIAN-ACADEMY", NULL
};
101 char *georgian_ps
[] = {"GEORGIAN-PS", NULL
};
102 char *ibm_cp1133
[] = {"CP850" , NULL
};
103 char *isiri_3342
[] = {"ISIRI-3342", NULL
};
104 /* embed ascii into ISO-8859-1*/
105 char *iso8859_1
[] = {"ISO-8859-1", /* gnu */
106 "ISO8859-1", /* aix, irix, osf, solaris */
107 "iso8859-1", /* aix, irix, osf */
108 "iso88591", /* hpux */
109 "8859-1", /* solaris ? */
115 "ISO_646.IRV:1983", /* old glibc */
118 char *iso8859_2
[] = {"ISO-8859-2",
125 char *iso8859_3
[] = {"ISO-8859-3",
132 char *iso8859_4
[] = {"ISO-8859-4",
139 char *iso8859_5
[] = {"ISO-8859-5",
146 char *iso8859_6
[] = {"ISO-8859-6",
153 char *iso8859_7
[] = {"ISO-8859-7",
160 char *iso8859_8
[] = {"ISO-8859-8",
167 char *iso8859_9
[] = {"ISO-8859-9",
174 char *iso8859_10
[] = {"ISO-8859-10",
182 char *iso8859_13
[] = {"ISO-8859-13",
191 char *iso8859_14
[] = {"ISO-8859-14",
199 char *iso8859_15
[] = {"ISO-8859-15",
207 char *iso8859_16
[] = {"ISO-8859-16",
215 char *jisx0201_1976_0
[] = {"JIS_X0201",
219 char *jisx0208_1983_0
[] = {"JIS_X0208", NULL
};
220 char *jisx0208_1990_0
[] = {"JIS_X0208", NULL
};
221 char *jisx0212_1990_0
[] = {"JIS_X0212", NULL
};
222 char *koi8_r
[] = {"KOI8-R", /* gnu, solaris */
224 char *koi8_u
[] = {"KOI8-U",
226 char *ksc5601
[] = {"KSC5636",
227 "ko_KR-johap", /* solaris */
236 char *microsoft_cp1251
[] = {"CP1251",
238 char *microsoft_cp1255
[] = {"CP1255",
240 char *microsoft_cp1256
[] = {"CP1256",
242 char *mulelao_1
[] = {"MULELAO-1",
245 char *sjisx_1
[] = {"SHIFT_JIS",
246 "SJIS", /* solaris, osf */
250 char *tatar_cyr
[] = {NULL
};
251 char *tcvn_5712
[] = {"TCVN", NULL
};
252 char *tis620_0
[] = {"TIS-620",
256 char *viscii1_1_1
[] = {"VISCII", NULL
};
257 /* encofing only ...*/
258 char *utf_8
[] = {"UTF-8", /* gnu, solaris */
263 char *usc_2
[] = {"USC-2",
269 char *usc_4
[] = {"USC-4",
275 char *utf_16
[] = {"UTF-16",
280 char *euc_jp
[] = {"EUC-JP",
291 #define CT_ENTRY(x,y,z) \
292 {x, y, FLC_INDEX_ICONV_CHARSET_NOT_INITIALIZED, z, FLC_ENCODING_TYPE_FONT}
293 #define CT_ENTRY_WET(x,y,z,t) \
294 {x, y, FLC_INDEX_ICONV_CHARSET_NOT_INITIALIZED, z, t}
296 #define CT_ENTRY(x,y,z) \
297 {x, y, FLC_INDEX_ICONV_CHARSET_NOT_INITIALIZED, NULL, FLC_ENCODING_TYPE_FONT}
298 #define CT_ENTRY_WET(x,y,z,t) \
299 {x, y, FLC_INDEX_ICONV_CHARSET_NOT_INITIALIZED, NULL, t}
302 #else /* !FlocaleIconvSupport */
305 #define CT_ENTRY(x,y,z) \
306 {x, nullsl, FLC_INDEX_ICONV_CHARSET_NOT_FOUND, z, FLC_ENCODING_TYPE_FONT}
307 #define CT_ENTRY_WET(x,y,z,t) \
308 {x, nullsl, FLC_INDEX_ICONV_CHARSET_NOT_FOUND, z, t}
310 #define CT_ENTRY(x,y,z) \
311 {x, nullsl, FLC_INDEX_ICONV_CHARSET_NOT_FOUND, NULL, FLC_ENCODING_TYPE_FONT}
312 #define CT_ENTRY_WET(x,y,z,t) \
313 {x, nullsl, FLC_INDEX_ICONV_CHARSET_NOT_FOUND, NULL, t}
319 FlocaleCharset UnknownCharset
=
320 {"Unknown", nullsl
, FLC_INDEX_ICONV_CHARSET_NOT_FOUND
, NULL
};
322 /* the table contains all Xorg "charset" plus some others */
324 FlocaleCharset FlocaleCharsetTable
[] =
326 CT_ENTRY("ARMSCII-8", armscii_8
, NULL
),
327 CT_ENTRY("BIG5-0", big5_0
, NULL
),
328 CT_ENTRY("BIG5HKSCS-0", big5hkscs_0
, NULL
),
329 CT_ENTRY("CNS11643.1986-1", cns11643
, NULL
),
330 CT_ENTRY("CNS11643.1986-2", cns11643
, NULL
),
331 CT_ENTRY("CNS11643.1992-3", cns11643
, NULL
),
332 CT_ENTRY("CNS11643.1992-4", cns11643
, NULL
),
333 CT_ENTRY("CNS11643.1992-5", cns11643
, NULL
),
334 CT_ENTRY("CNS11643.1992-6", cns11643
, NULL
),
335 CT_ENTRY("CNS11643.1992-7", cns11643
, NULL
),
336 CT_ENTRY("DOSENCODING-CP437", dosencoding_cp437
, NULL
),
337 CT_ENTRY("DOSENCODING-CP850", dosencoding_cp850
, NULL
),
338 CT_ENTRY("EUC-JP", euc_jp
, NULL
),
339 CT_ENTRY("GB2312.1980-0", gb2312_1980_0
, NULL
),
340 CT_ENTRY("GBK-0", gbk_0
, NULL
),
341 CT_ENTRY("GEORGIAN-ACADEMY", georgian_academy
, NULL
),
342 CT_ENTRY("GEORGIAN-PS", georgian_ps
, NULL
),
343 CT_ENTRY("IBM-CP1133", ibm_cp1133
, NULL
),
344 CT_ENTRY("ISIRI-3342", isiri_3342
, "ISIRI-3342"),
345 /* exception ISO10646-1 implies UTF-8 and not USC-2 ! */
346 CT_ENTRY_WET("ISO10646-1", utf_8
, "UTF-8", FLC_ENCODING_TYPE_UTF_8
),
347 CT_ENTRY("ISO8859-1", iso8859_1
, NULL
),
348 CT_ENTRY("ISO8859-2", iso8859_2
, NULL
),
349 CT_ENTRY("ISO8859-3", iso8859_3
, NULL
),
350 CT_ENTRY("ISO8859-4", iso8859_4
, NULL
),
351 CT_ENTRY("ISO8859-5", iso8859_5
, NULL
),
352 CT_ENTRY("ISO8859-6", iso8859_6
, "ISO8859-6"),
353 CT_ENTRY("ISO8859-6.8X", iso8859_6
, "ISO8859-6"),
354 CT_ENTRY("ISO8859-7", iso8859_7
, NULL
),
355 CT_ENTRY("ISO8859-8", iso8859_8
, "ISO8859-8"),
356 CT_ENTRY("ISO8859-9", iso8859_9
, NULL
),
357 CT_ENTRY("ISO8859-9E", iso8859_9
, NULL
),
358 CT_ENTRY("ISO8859-10", iso8859_10
, NULL
),
359 CT_ENTRY("ISO8859-13", iso8859_13
, NULL
),
360 CT_ENTRY("ISO8859-14", iso8859_14
, NULL
),
361 CT_ENTRY("ISO8859-15", iso8859_15
, NULL
),
362 CT_ENTRY("ISO8859-16", iso8859_16
, NULL
),
363 CT_ENTRY("JISX.UDC-1", jisx0201_1976_0
, NULL
), /* ? */
364 CT_ENTRY("JISX0201.1976-0", jisx0201_1976_0
, NULL
),
365 CT_ENTRY("JISX0208.1983-0", jisx0208_1983_0
, NULL
),
366 CT_ENTRY("JISX0208.1990-0", jisx0208_1990_0
, NULL
),
367 CT_ENTRY("JISX0212.1990-0", jisx0212_1990_0
, NULL
),
368 CT_ENTRY("KOI8-C", koi8_r
, NULL
),
369 CT_ENTRY("KOI8-R", koi8_r
, NULL
),
370 CT_ENTRY("KOI8-U", koi8_u
, NULL
),
371 CT_ENTRY("KSC5601.1987-0", ksc5601
, NULL
),
372 CT_ENTRY("KSC5601.1992-0", ksc5601
, NULL
),
373 CT_ENTRY("MICROSOFT-CP1251", microsoft_cp1251
, NULL
),
374 CT_ENTRY("MICROSOFT-CP1255", microsoft_cp1255
, "CP1255"),
375 CT_ENTRY("MICROSOFT-CP1256", microsoft_cp1256
, "CP1256"),
376 CT_ENTRY("MULELAO-1", mulelao_1
, NULL
),
377 CT_ENTRY("SJISX-1", sjisx_1
, NULL
),
378 CT_ENTRY("TATAR-CYR", tatar_cyr
, NULL
),
379 CT_ENTRY("TCVN-5712", tcvn_5712
, NULL
),
380 CT_ENTRY("TIS620-0", tis620_0
, NULL
),
381 CT_ENTRY("VISCII1.1-1", viscii1_1_1
, NULL
),
383 /* CT_ENTRY("ADOBE-STANDARD", iso8859_1, NULL), no! */
384 CT_ENTRY("ASCII-0", iso8859_1
, NULL
),
385 CT_ENTRY("BIBIG5HKSCS", big5_0
, NULL
), /* ? */
386 CT_ENTRY("BIG5-E0", big5_0
, NULL
), /* emacs */
387 CT_ENTRY("BIG5-E1", big5_0
, NULL
), /* emacs */
388 CT_ENTRY("BIG5-1", big5_0
, NULL
),
389 CT_ENTRY("ISO646.1991-IRV", iso8859_1
, NULL
),
390 CT_ENTRY("TIS620.2533-1", tis620_0
, NULL
),
391 CT_ENTRY_WET("UTF-8", utf_8
, "UTF-8", FLC_ENCODING_TYPE_UTF_8
),
392 CT_ENTRY_WET("USC-2", usc_2
, "USC-2", FLC_ENCODING_TYPE_USC_2
),
393 CT_ENTRY_WET("USC-4", usc_4
, NULL
, FLC_ENCODING_TYPE_USC_4
),
394 CT_ENTRY_WET("UTF-16", utf_16
, NULL
, FLC_ENCODING_TYPE_UTF_16
),
395 CT_ENTRY(NULL
, nullsl
, NULL
)
398 /* to be supported: ADOBE-STANDARD, some Xft1 charset */
400 /* ---------------------------- exported variables (globals) --------------- */
402 /* ---------------------------- local functions ---------------------------- */
405 FlocaleCharset
*FlocaleCharsetOfXCharset(char *x
)
409 while(FlocaleCharsetTable
[j
].x
!= NULL
)
411 if (StrEquals(x
,FlocaleCharsetTable
[j
].x
))
413 return &FlocaleCharsetTable
[j
];
421 FlocaleCharset
*FlocaleCharsetOfLocaleCharset(char *l
)
425 while(FlocaleCharsetTable
[j
].x
!= NULL
)
427 if (StrEquals(l
, FlocaleCharsetTable
[j
].x
))
429 return &FlocaleCharsetTable
[j
];
432 while(FlocaleCharsetTable
[j
].locale
[i
] != NULL
)
434 if (StrEquals(l
, FlocaleCharsetTable
[j
].locale
[i
]))
436 return &FlocaleCharsetTable
[j
];
446 FlocaleCharset
*FlocaleCharsetOfFontStruct(Display
*dpy
, XFontStruct
*fs
)
448 unsigned long value
= 0;
456 if (!XGetFontProperty(fs
, XA_FONT
, &value
))
460 if ((name
= XGetAtomName(dpy
, value
)) == NULL
)
466 while (*tmp
!= '\0' && count
< 13)
475 fc
= FlocaleCharsetOfXCharset(tmp
);
485 void FlocaleInit_X_Charset(Display
*dpy
, const char *module
)
487 #ifdef HAVE_XOUTPUT_METHOD
492 om
= XOpenOM(dpy
, NULL
, NULL
, NULL
);
493 if (om
&& XGetOMValues(om
, XNRequiredCharSet
, &cs
, NULL
) == NULL
)
495 if (cs
.charset_count
> 0)
497 if (FLCXOMCharsetList
!= NULL
)
499 free(FLCXOMCharsetList
);
501 FLCXOMCharsetList_num
= cs
.charset_count
;
502 FLCXOMCharsetList
= (FlocaleCharset
**)safemalloc(
503 sizeof(FlocaleCharset
) * cs
.charset_count
);
504 for (i
= 0; i
< FLCXOMCharsetList_num
; i
++)
506 FLCXOMCharsetList
[i
] =
507 FlocaleCharsetOfXCharset(
509 #if FLOCALE_DEBUG_CHARSET
511 "[FlocaleInitCharset] XOM charset "
514 FLC_DEBUG_GET_X_CHARSET(
515 FLCXOMCharsetList
[i
]),
516 FLC_DEBUG_GET_BIDI_CHARSET (
517 FLCXOMCharsetList
[i
]));
526 if (FLCXOMCharsetList_num
> 0 && FLCXOMCharsetList
[0])
530 if (FLCLocaleCharset
!= NULL
)
532 best_charset
= FLCLocaleCharset
->x
;
533 #if FLOCALE_DEBUG_CHARSET
535 "[FlocaleInitCharset] FLCLocaleCharset: %s\n",
541 best_charset
= FLOCALE_FALLBACK_XCHARSET
;
542 #if FLOCALE_DEBUG_CHARSET
544 "[FlocaleInitCharset] FALLBACK: %s\n",
549 FLCXOMCharset
= FLCXOMCharsetList
[0];
550 if (best_charset
== NULL
)
552 /* should not happen */
556 for(i
= 0; i
< FLCXOMCharsetList_num
; i
++)
560 FLC_DEBUG_GET_X_CHARSET(
561 FLCXOMCharsetList
[i
])))
563 FLCXOMCharset
= FLCXOMCharsetList
[i
];
568 #if FLOCALE_DEBUG_CHARSET
570 "[FlocaleInitCharset] XOM charset "
573 FLC_DEBUG_GET_X_CHARSET(FLCXOMCharset
));
579 /* ---------------------------- interface functions ------------------------ */
581 void FlocaleCharsetInit(Display
*dpy
, const char *module
)
583 static Bool initialized
= False
;
586 if (initialized
== True
)
592 /* try to find the regular charset */
593 charset
= getenv("CHARSET");
594 #if FLOCALE_DEBUG_CHARSET
596 "[FlocaleInitCharset] CHARSET: %s\n", (!charset
)? "null":charset
);
598 if ((!charset
|| strlen(charset
) < 3) && FlocaleLibcharsetSupport
)
600 charset
= (char *)Flocale_charset();
601 #if FLOCALE_DEBUG_CHARSET
604 "[FlocaleInitCharset] FlocaleLibcharsetSupport: %s\n",
605 (!charset
)? "null":charset
);
608 if ((!charset
|| strlen(charset
) < 3) && FlocaleCodesetSupport
)
610 charset
= Fnl_langinfo(FCODESET
);
611 #if FLOCALE_DEBUG_CHARSET
614 "[FlocaleInitCharset] Fnl_langinfo: %s\n",
615 (!charset
)? "null":charset
);
618 if (charset
!= NULL
&& strlen(charset
) > 2)
621 FlocaleCharsetOfLocaleCharset(charset
);
622 #if FLOCALE_DEBUG_CHARSET
625 "[FlocaleInitCharset] FLCLocaleCharset: %s\n", charset
);
629 /* set the defaults X locale charsets */
630 FlocaleInit_X_Charset(dpy
, module
);
633 FLCUtf8Charset
= FlocaleCharsetOfXCharset(FLOCALE_UTF8_XCHARSET
);
635 #if FLOCALE_DEBUG_CHARSET
636 fprintf(stderr
,"[FlocaleCharsetInit] locale charset: x:%s, bidi:%s\n",
637 FLC_DEBUG_GET_X_CHARSET(FLCXOMCharset
),
638 FLC_DEBUG_GET_BIDI_CHARSET (FLCXOMCharset
));
639 fprintf(stderr
,"[FlocaleCharsetInit] locale charset: x:%s, bidi:%s\n",
640 FLC_DEBUG_GET_X_CHARSET(FLCLocaleCharset
),
641 FLC_DEBUG_GET_BIDI_CHARSET (FLCLocaleCharset
));
647 void FlocaleCharsetSetFlocaleCharset(
648 Display
*dpy
, FlocaleFont
*flf
, char *hints
, char *encoding
,
651 char *charset
= NULL
;
653 Bool iconv_found
= False
;
656 FlocaleCharsetInit(dpy
, module
);
660 iconv
= GetQuotedString(
661 hints
, &charset
, "/", NULL
, NULL
, NULL
);
662 if (charset
&& *charset
&& *charset
!= '*' )
664 flf
->fc
= FlocaleCharsetOfXCharset(charset
);
666 if (flf
->fc
== NULL
&& charset
&& *charset
&& *charset
!= '*')
668 flf
->fc
= FlocaleCharsetOfLocaleCharset(charset
);
670 if (flf
->fc
== NULL
&& iconv
&& *iconv
)
672 flf
->fc
= FlocaleCharsetOfLocaleCharset(iconv
);
677 if (FftSupport
&& flf
->fftf
.fftfont
!= NULL
)
679 flf
->fc
= FlocaleCharsetOfXCharset(flf
->fftf
.encoding
);
681 else if (flf
->fontset
!= None
)
683 if (FLCXOMCharset
!= NULL
)
685 flf
->fc
= FLCXOMCharset
;
689 /* we are here if !HAVE_XOUTPUT_METHOD */
690 XFontStruct
**fs_list
;
694 flf
->fontset
, &fs_list
, &ml
) > 0)
696 flf
->fc
= FLCXOMCharset
=
697 FlocaleCharsetOfFontStruct(
702 else if (flf
->font
!= NULL
)
704 flf
->fc
= FlocaleCharsetOfFontStruct(dpy
, flf
->font
);
707 if (flf
->fc
!= NULL
&& iconv
&& *iconv
)
709 /* the user has specified an iconv converter name:
710 * check if we have it and force user choice */
711 while(!iconv_found
&&
712 FLC_GET_LOCALE_CHARSET(flf
->fc
,i
) != NULL
)
717 FLC_GET_LOCALE_CHARSET(flf
->fc
,i
)) ==
721 /* Trust the user? yes ... */
722 FLC_SET_ICONV_INDEX(flf
->fc
,i
);
727 if (iconv
&& *iconv
&& !iconv_found
)
731 /* the user has specified an iconv converter name and we do not
732 * have it: must create a FlocaleCharset */
733 flf
->flags
.must_free_fc
= True
;
734 fc
= (FlocaleCharset
*)safemalloc(sizeof(FlocaleCharset
));
737 CopyString(&fc
->x
, flf
->fc
->x
);
738 fc
->encoding_type
= flf
->fc
->encoding_type
;
740 CopyString(&fc
->bidi
, flf
->fc
->bidi
);
746 CopyString(&fc
->x
, "Unknown"); /* for simplicity */
748 fc
->encoding_type
= FLC_ENCODING_TYPE_FONT
;
750 fc
->locale
= (char **)safemalloc(2*sizeof(char *));
751 CopyString(&fc
->locale
[0], iconv
);
752 fc
->locale
[1] = NULL
;
753 fc
->iconv_index
= FLC_INDEX_ICONV_CHARSET_NOT_INITIALIZED
;
762 flf
->fc
= &UnknownCharset
;
765 /* now the string charset */
766 if (encoding
!= NULL
)
768 flf
->str_fc
= FlocaleCharsetOfXCharset(encoding
);
769 if (flf
->str_fc
== NULL
)
771 flf
->str_fc
= FlocaleCharsetOfLocaleCharset(encoding
);
773 if (flf
->str_fc
== NULL
)
775 flf
->str_fc
= &UnknownCharset
;
778 else if (FftSupport
&& flf
->fftf
.fftfont
!= NULL
)
780 if (flf
->fftf
.str_encoding
!= NULL
)
782 flf
->str_fc
= FlocaleCharsetOfXCharset(
783 flf
->fftf
.str_encoding
);
784 if (flf
->str_fc
== NULL
)
786 flf
->str_fc
= FlocaleCharsetOfLocaleCharset(
787 flf
->fftf
.str_encoding
);
789 if (flf
->str_fc
== NULL
)
791 flf
->str_fc
= &UnknownCharset
;
797 FlocaleCharsetGetDefaultCharset(dpy
, module
);
800 if (flf
->str_fc
== NULL
)
802 if (flf
->fc
!= &UnknownCharset
)
804 flf
->str_fc
= flf
->fc
;
809 FlocaleCharsetGetDefaultCharset(dpy
, module
);
814 FlocaleCharset
*FlocaleCharsetGetDefaultCharset(Display
*dpy
, char *module
)
816 static int warn
= True
;
818 FlocaleCharsetInit(dpy
, module
);
820 if (FLCXOMCharset
!= NULL
)
821 return FLCXOMCharset
;
822 if (FLCLocaleCharset
!= NULL
)
823 return FLCLocaleCharset
;
829 "[%s][%s]: WARN -- Cannot find default locale "
831 (module
!= NULL
)? module
:"FVWMlibs",
832 "FlocaleGetDefaultCharset");
833 fprintf(stderr
,"X Ouput Method ");
834 fprintf(stderr
,", CHARSET env variable");
835 if (FlocaleLibcharsetSupport
)
836 fprintf(stderr
,", locale_charset");
837 if (FlocaleCodesetSupport
)
838 fprintf(stderr
,", nl_langinfo");
839 fprintf(stderr
,"\n");
842 FlocaleCharsetOfXCharset(FLOCALE_FALLBACK_XCHARSET
);
843 fprintf(stderr
,"\tUse default charset: %s\n",
844 FLOCALE_FALLBACK_XCHARSET
);
847 return FLCLocaleCharset
;
850 FlocaleCharset
*FlocaleCharsetGetFLCXOMCharset(void)
852 return FLCXOMCharset
;
855 FlocaleCharset
*FlocaleCharsetGetUtf8Charset(void)
857 return FLCUtf8Charset
;
860 FlocaleCharset
*FlocaleCharsetGetLocaleCharset(void)
862 return FLCLocaleCharset
;
865 FlocaleCharset
*FlocaleCharsetGetUnknownCharset(void)
867 return &UnknownCharset
;
870 const char *FlocaleGetBidiCharset(Display
*dpy
, FlocaleCharset
*fc
)
872 if (fc
== NULL
|| fc
== FlocaleCharsetGetUnknownCharset() ||
877 return (const char *)fc
->bidi
;
881 FlocaleCharset
*FlocaleCharsetGetEUCJPCharset(void)
883 static FlocaleCharset
*fc
= NULL
;
889 fc
= FlocaleCharsetOfXCharset("EUC-JP");
893 Bool
FlocaleCharsetIsCharsetXLocale(Display
*dpy
, char *charset
, char *module
)
895 #ifdef HAVE_XOUTPUT_METHOD
898 FlocaleCharsetInit(dpy
, module
);
899 if (FLCXOMCharsetList_num
> 0)
901 for(i
= 0; i
< FLCXOMCharsetList_num
; i
++)
904 FLC_DEBUG_GET_X_CHARSET(
905 FLCXOMCharsetList
[i
]),
914 return True
; /* Hum */
918 void FlocaleCharsetPrintXOMInfo(void)
920 #ifdef HAVE_XOUTPUT_METHOD
923 fprintf(stderr
," XOM Charsets: ");
924 if (FLCXOMCharsetList_num
> 0)
926 for(i
= 0; i
< FLCXOMCharsetList_num
; i
++)
930 FLC_DEBUG_GET_X_CHARSET(FLCXOMCharsetList
[i
]));
933 fprintf(stderr
,"\n");