encoding fixes
This commit is contained in:
parent
7b8c1815ae
commit
42091deffc
@ -68,10 +68,20 @@ static inline seq_encoding_t seq_encoding(encoding_t inp) {
|
||||
if (inp == 0)
|
||||
return 0L;
|
||||
// if (inp & ((CELL)0xffffL << 16)) {inp >>= 16; out += 16;}
|
||||
if (inp & ((CELL)0xffL << 8)) {inp >>= 8; out += 8;}
|
||||
if (inp & ((CELL)0xfL << 4)) {inp >>= 4; out += 4;}
|
||||
if (inp & ((CELL)0x3L << 2)) {inp >>= 2; out += 2;}
|
||||
if (inp & ((CELL)0x1 << 1)) out++;
|
||||
if (inp & ((CELL)0xffL << 8)) {
|
||||
inp >>= 8;
|
||||
out += 8;
|
||||
}
|
||||
if (inp & ((CELL)0xfL << 4)) {
|
||||
inp >>= 4;
|
||||
out += 4;
|
||||
}
|
||||
if (inp & ((CELL)0x3L << 2)) {
|
||||
inp >>= 2;
|
||||
out += 2;
|
||||
}
|
||||
if (inp & ((CELL)0x1 << 1))
|
||||
out++;
|
||||
#endif
|
||||
return out;
|
||||
}
|
||||
@ -79,38 +89,53 @@ static inline seq_encoding_t seq_encoding(encoding_t inp) {
|
||||
extern xlocale enc_locales[SEQ_ENC_ISO_UTF32_LE + 1];
|
||||
#endif
|
||||
|
||||
|
||||
static inline const char *enc_name(encoding_t enc)
|
||||
{
|
||||
switch(enc)
|
||||
{
|
||||
case ENC_OCTET: return "octet";
|
||||
case ENC_ISO_LATIN1: return "iso_latin_1";
|
||||
case ENC_ISO_ASCII: return "ascii";
|
||||
case ENC_ISO_ANSI: return "octet";
|
||||
case ENC_ISO_UTF8: return "utf8";
|
||||
case ENC_UTF16_BE: return "utf16_be";
|
||||
case ENC_UTF16_LE: return "utf16_le";
|
||||
case ENC_ISO_UTF32_BE: return "utf32_be";
|
||||
case ENC_ISO_UTF32_LE: return "utf32_le";
|
||||
default: return "thanks for watching!!";
|
||||
static inline const char *enc_name(encoding_t enc) {
|
||||
switch (enc) {
|
||||
case ENC_OCTET:
|
||||
return "octet";
|
||||
case ENC_ISO_LATIN1:
|
||||
return "iso_latin_1";
|
||||
case ENC_ISO_ASCII:
|
||||
return "ascii";
|
||||
case ENC_ISO_ANSI:
|
||||
return "octet";
|
||||
case ENC_ISO_UTF8:
|
||||
return "utf8";
|
||||
case ENC_UTF16_BE:
|
||||
return "utf16_be";
|
||||
case ENC_UTF16_LE:
|
||||
return "utf16_le";
|
||||
case ENC_ISO_UTF32_BE:
|
||||
return "utf32_be";
|
||||
case ENC_ISO_UTF32_LE:
|
||||
return "utf32_le";
|
||||
default:
|
||||
return "thanks for watching!!";
|
||||
}
|
||||
}
|
||||
|
||||
static inline
|
||||
encoding_t enc_id(char *s)
|
||||
static inline encoding_t enc_id(char *s) {
|
||||
{
|
||||
{
|
||||
if (!strcmp(s, "iso_utf8")) return ENC_ISO_UTF8;
|
||||
if (!strcmp(s, "utf16_be")) return ENC_UTF16_BE;
|
||||
if (!strcmp(s, "utf16_le")) return ENC_UTF16_LE;
|
||||
if (!strcmp(s, "octet")) return ENC_OCTET;
|
||||
if (!strcmp(s, "iso_latin_1")) return ENC_ISO_LATIN1;
|
||||
if (!strcmp(s, "iso_ascii")) return ENC_ISO_ASCII;
|
||||
if (!strcmp(s, "iso_ansi")) return ENC_ISO_ANSI;
|
||||
if (!strcmp(s, "utf32_be")) return ENC_ISO_UTF32_BE;
|
||||
if (!strcmp(s, "utf32_le")) return ENC_ISO_UTF32_LE;
|
||||
if (!strcmp(s, "default")) return Yap_DefaultEncoding();
|
||||
if (!strcmp(s, "iso_utf8"))
|
||||
return ENC_ISO_UTF8;
|
||||
if (!strcmp(s, "utf8"))
|
||||
return ENC_ISO_UTF8;
|
||||
if (!strcmp(s, "utf16_le"))
|
||||
return ENC_UTF16_LE;
|
||||
if (!strcmp(s, "octet"))
|
||||
return ENC_OCTET;
|
||||
if (!strcmp(s, "iso_latin_1"))
|
||||
return ENC_ISO_LATIN1;
|
||||
if (!strcmp(s, "iso_ascii"))
|
||||
return ENC_ISO_ASCII;
|
||||
if (!strcmp(s, "iso_ansi"))
|
||||
return ENC_ISO_ANSI;
|
||||
if (!strcmp(s, "utf32_be"))
|
||||
return ENC_ISO_UTF32_BE;
|
||||
if (!strcmp(s, "utf32_le"))
|
||||
return ENC_ISO_UTF32_LE;
|
||||
if (!strcmp(s, "default"))
|
||||
return Yap_DefaultEncoding();
|
||||
else {
|
||||
Yap_Error(DOMAIN_ERROR_OUT_OF_RANGE, 0, "bad encoding %s", s);
|
||||
return ENC_OCTET;
|
||||
@ -121,4 +146,3 @@ encoding_t enc_id(char *s)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user