29typedef enum YAP_encoding {
37 ENC_ISO_UTF32_BE = 64,
38 ENC_ISO_UTF32_LE = 128,
44#define ENC_WCHAR ENC_ISO_UTF32_BE
46#define ENC_WCHAR ENC_ISO_UTF32_LE
52encoding_t Yap_DefaultEncoding(
void);
53encoding_t Yap_SystemEncoding(
void);
54void Yap_SetDefaultEncoding(encoding_t new_encoding);
70static inline seq_encoding_t seq_encoding(encoding_t inp) {
71#if HAVE__BUILTIN_FFSLL
72 return __builtin_ffsll(inp);
81 if (inp & ((CELL)0xffL << 8)) {
85 if (inp & ((CELL)0xfL << 4)) {
89 if (inp & ((CELL)0x3L << 2)) {
93 if (inp & ((CELL)0x1 << 1))
99extern xlocale enc_locales[SEQ_ENC_ISO_UTF32_LE + 1];
102static inline const char *enc_name(encoding_t enc) {
107 return "iso_latin_1";
122 case ENC_ISO_UTF32_BE:
124 case ENC_ISO_UTF32_LE:
127 return "thanks for watching!!";
131static inline encoding_t enc_id(
const char *s, encoding_t enc_bom) {
133 if (!strcmp(s,
"iso_utf8"))
135 if (!strcmp(s,
"utf8"))
137 if (!strcmp(s,
"UTF-8"))
139 if (!strcmp(s,
"utf16_le"))
141 if (!strcmp(s,
"utf16_be"))
143 if (!strcmp(s,
"UTF-16")) {
144 if (enc_bom == ENC_UTF16_LE)
148 if (!strcmp(s,
"UTF-16LE"))
150 if (!strcmp(s,
"UTF-16BE"))
152 if (!strcmp(s,
"octet"))
154 if (!strcmp(s,
"iso_latin_1"))
155 return ENC_ISO_LATIN1;
156 if (!strcmp(s,
"iso_ascii"))
157 return ENC_ISO_ASCII;
158 if (!strcmp(s,
"iso_ansi"))
160 if (!strcmp(s,
"utf32_be"))
161 return ENC_ISO_UTF32_BE;
162 if (!strcmp(s,
"utf32_le"))
163 return ENC_ISO_UTF32_LE;
164 if (!strcmp(s,
"UTF-32")) {
165 if (enc_bom == ENC_ISO_UTF32_LE)
166 return ENC_ISO_UTF32_LE;
167 return ENC_ISO_UTF32_BE;
169 if (!strcmp(s,
"UTF-32BE"))
170 return ENC_ISO_UTF32_BE;
171 if (!strcmp(s,
"UTF-32LE"))
172 return ENC_ISO_UTF32_LE;
173 if (!strcmp(s,
"ISO-8859-1"))
174 return ENC_ISO_LATIN1;
175 if (!strcmp(s,
"US_ASCII"))
176 return ENC_ISO_ASCII;
179 if (!strcmp(s,
"unicode_be"))
181 if (!strcmp(s,
"unicode_le"))
183 if (!strcmp(s,
"UCS-2")) {
184 if (enc_bom == ENC_UTF16_LE)
188 if (!strcmp(s,
"UCS-2LE"))
190 if (!strcmp(s,
"UCS-2BE"))
192 if (!strcmp(s,
"default")) {
193 if (enc_bom != ENC_OCTET)
195 return Yap_DefaultEncoding();
197 return Yap_DefaultEncoding();