This source file includes following definitions.
- locale_encoding_classification_uncached
- locale_encoding_classification_cached
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <config.h>
20
21
22 #include "lc-charset-dispatch.h"
23
24 #if GNULIB_defined_mbstate_t
25
26 # include "localcharset.h"
27 # include "streq.h"
28
29 # if GNULIB_WCHAR_SINGLE_LOCALE
30
31
32 # define locale_encoding_classification_cached locale_encoding_classification
33 # else
34
35 # define locale_encoding_classification_uncached locale_encoding_classification
36 # endif
37
38 # if GNULIB_WCHAR_SINGLE_LOCALE
39 static inline
40 # endif
41 enc_t
42 locale_encoding_classification_uncached (void)
43 {
44 const char *encoding = locale_charset ();
45 if (STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0))
46 return enc_utf8;
47 if (STREQ_OPT (encoding, "EUC-JP", 'E', 'U', 'C', '-', 'J', 'P', 0, 0, 0))
48 return enc_eucjp;
49 if (STREQ_OPT (encoding, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
50 || STREQ_OPT (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
51 || STREQ_OPT (encoding, "BIG5", 'B', 'I', 'G', '5', 0, 0, 0, 0, 0))
52 return enc_94;
53 if (STREQ_OPT (encoding, "EUC-TW", 'E', 'U', 'C', '-', 'T', 'W', 0, 0, 0))
54 return enc_euctw;
55 if (STREQ_OPT (encoding, "GB18030", 'G', 'B', '1', '8', '0', '3', '0', 0, 0))
56 return enc_gb18030;
57 if (STREQ_OPT (encoding, "SJIS", 'S', 'J', 'I', 'S', 0, 0, 0, 0, 0))
58 return enc_sjis;
59 return enc_other;
60 }
61
62 # if GNULIB_WCHAR_SINGLE_LOCALE
63
64 static int cached_locale_enc = -1;
65
66 enc_t
67 locale_encoding_classification_cached (void)
68 {
69 if (cached_locale_enc < 0)
70 cached_locale_enc = locale_encoding_classification_uncached ();
71 return cached_locale_enc;
72 }
73
74 # endif
75
76 #else
77
78
79
80 typedef int dummy;
81
82 #endif