len = 0;
if (encoding->flag & MBFL_ENCTYPE_SBCS) {
len = string->len;
- } else if (encoding->flag & (MBFL_ENCTYPE_WCS2BE | MBFL_ENCTYPE_WCS2LE)) {
+ } else if (encoding->flag & MBFL_ENCTYPE_WCS2) {
len = string->len/2;
- } else if (encoding->flag & (MBFL_ENCTYPE_WCS4BE | MBFL_ENCTYPE_WCS4LE)) {
+ } else if (encoding->flag & MBFL_ENCTYPE_WCS4) {
len = string->len/4;
} else if (encoding->mblen_table != NULL) {
const unsigned char *mbtab = encoding->mblen_table;
mbfl_string_init(result);
result->encoding = string->encoding;
- if ((encoding->flag & (MBFL_ENCTYPE_SBCS | MBFL_ENCTYPE_WCS2BE | MBFL_ENCTYPE_WCS2LE | MBFL_ENCTYPE_WCS4BE | MBFL_ENCTYPE_WCS4LE)) ||
+ if ((encoding->flag & (MBFL_ENCTYPE_SBCS | MBFL_ENCTYPE_WCS2 | MBFL_ENCTYPE_WCS4)) ||
encoding->mblen_table != NULL) {
len = string->len;
if (encoding->flag & MBFL_ENCTYPE_SBCS) {
start = from;
- } else if (encoding->flag & (MBFL_ENCTYPE_WCS2BE | MBFL_ENCTYPE_WCS2LE)) {
+ } else if (encoding->flag & MBFL_ENCTYPE_WCS2) {
start = from*2;
- } else if (encoding->flag & (MBFL_ENCTYPE_WCS4BE | MBFL_ENCTYPE_WCS4LE)) {
+ } else if (encoding->flag & MBFL_ENCTYPE_WCS4) {
start = from*4;
} else {
const unsigned char *mbtab = encoding->mblen_table;
end = len;
} else if (encoding->flag & MBFL_ENCTYPE_SBCS) {
end = start + length;
- } else if (encoding->flag & (MBFL_ENCTYPE_WCS2BE | MBFL_ENCTYPE_WCS2LE)) {
+ } else if (encoding->flag & MBFL_ENCTYPE_WCS2) {
end = start + length*2;
- } else if (encoding->flag & (MBFL_ENCTYPE_WCS4BE | MBFL_ENCTYPE_WCS4LE)) {
+ } else if (encoding->flag & MBFL_ENCTYPE_WCS4) {
end = start + length*4;
} else {
const unsigned char *mbtab = encoding->mblen_table;
mbfl_string_init(result);
result->encoding = string->encoding;
- if ((encoding->flag & (MBFL_ENCTYPE_SBCS
- | MBFL_ENCTYPE_WCS2BE
- | MBFL_ENCTYPE_WCS2LE
- | MBFL_ENCTYPE_WCS4BE
- | MBFL_ENCTYPE_WCS4LE))
- || encoding->mblen_table != NULL) {
+ if ((encoding->flag & (MBFL_ENCTYPE_SBCS | MBFL_ENCTYPE_WCS2 | MBFL_ENCTYPE_WCS4)) || encoding->mblen_table != NULL) {
const unsigned char *start = NULL;
const unsigned char *end = NULL;
unsigned char *w;
size_t sz;
- if (encoding->flag & (MBFL_ENCTYPE_WCS2BE | MBFL_ENCTYPE_WCS2LE)) {
+ if (encoding->flag & MBFL_ENCTYPE_WCS2) {
from &= -2;
if (length >= string->len - from) {
start = string->val + from;
end = start + (length & -2);
- } else if (encoding->flag & (MBFL_ENCTYPE_WCS4BE | MBFL_ENCTYPE_WCS4LE)) {
+ } else if (encoding->flag & MBFL_ENCTYPE_WCS4) {
from &= -4;
if (length >= string->len - from) {
#define MBFL_ENCTYPE_SBCS 0x00000001 /* single-byte encoding */
#define MBFL_ENCTYPE_MBCS 0x00000002 /* multi-byte encoding */
-#define MBFL_ENCTYPE_WCS2BE 0x00000010 /* 2 bytes/char, big endian */
-#define MBFL_ENCTYPE_WCS2LE 0x00000020 /* 2 bytes/char, little endian */
+#define MBFL_ENCTYPE_WCS2 0x00000010 /* 2 bytes/char */
#define MBFL_ENCTYPE_MWC2BE 0x00000040 /* 2+ bytes/char, big endian */
#define MBFL_ENCTYPE_MWC2LE 0x00000080 /* 2+ bytes/char, little endian */
-#define MBFL_ENCTYPE_WCS4BE 0x00000100 /* 4 bytes/char, big endian */
-#define MBFL_ENCTYPE_WCS4LE 0x00000200 /* 4 bytes/char, little endian */
+#define MBFL_ENCTYPE_WCS4 0x00000100 /* 4 bytes/char */
#define MBFL_ENCTYPE_GL_UNSAFE 0x00004000
/* wchar plane, special character */
if (mbfl_encoding->flag & MBFL_ENCTYPE_SBCS) { /* 1 byte */
mb_len = string.len;
chunk_len = (size_t)split_length; /* chunk length in bytes */
- } else if (mbfl_encoding->flag & (MBFL_ENCTYPE_WCS2BE | MBFL_ENCTYPE_WCS2LE)) { /* 2 bytes */
+ } else if (mbfl_encoding->flag & MBFL_ENCTYPE_WCS2) { /* 2 bytes */
mb_len = string.len / 2;
chunk_len = split_length * 2;
- } else if (mbfl_encoding->flag & (MBFL_ENCTYPE_WCS4BE | MBFL_ENCTYPE_WCS4LE)) { /* 4 bytes */
+ } else if (mbfl_encoding->flag & MBFL_ENCTYPE_WCS4) { /* 4 bytes */
mb_len = string.len / 4;
chunk_len = split_length * 4;
} else if (mbfl_encoding->mblen_table != NULL) {
if (enc->mblen_table != NULL) {
if (s != NULL) return enc->mblen_table[*(unsigned char *)s];
}
- } else if (enc->flag & (MBFL_ENCTYPE_WCS2BE | MBFL_ENCTYPE_WCS2LE)) {
+ } else if (enc->flag & MBFL_ENCTYPE_WCS2) {
return 2;
- } else if (enc->flag & (MBFL_ENCTYPE_WCS4BE | MBFL_ENCTYPE_WCS4LE)) {
+ } else if (enc->flag & MBFL_ENCTYPE_WCS4) {
return 4;
}
}