68 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
69 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1,
70 -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, 63,-1,-1,-1,
71 52,53,54,55, 56,57,58,59, 60,61,-1,-1, -1,-1,-1,-1,
72 -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14,
73 15,16,17,18, 19,20,21,22, 23,24,25,-1, -1,-1,-1,-1,
74 -1,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40,
75 41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1
83 'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
84 'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
85 'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
86 'n',
'o',
'p',
'q',
'r',
's',
't',
'u',
'v',
'w',
'x',
'y',
'z',
87 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'+',
',',
106static char *
utf7_to_utf8(
const char *u7,
size_t u7len,
char **u8,
size_t *u8len)
114 for (; u7len; u7++, u7len--)
121 if (u7len && (*u7 ==
'-'))
129 for (; u7len; u7++, u7len--)
131 if ((*u7 & 0x80) || ((b =
Index64u[(
int) *u7]) == -1))
143 if ((0x20 <= ch) && (ch < 0x7f))
152 *p++ = 0xc0 | (ch >> 6);
153 *p++ = 0x80 | (ch & 0x3f);
158 if ((ch & ~0x3ff) == 0xd800)
167 if ((ch & ~0x3ff) == 0xdc00)
172 ch = ((pair1 - 0xd800) << 10) + (ch - 0xdc00) + 0x10000;
180 *p++ = 0xe0 | (ch >> 12);
181 *p++ = 0x80 | ((ch >> 6) & 0x3f);
182 *p++ = 0x80 | (ch & 0x3f);
186 *p++ = 0xf0 | (ch >> 18);
187 *p++ = 0x80 | ((ch >> 12) & 0x3f);
188 *p++ = 0x80 | ((ch >> 6) & 0x3f);
189 *p++ = 0x80 | (ch & 0x3f);
194 ch = (b << (16 + k)) & 0xffff;
203 if (!u7len || (*u7 !=
'-'))
208 if ((u7len > 2) && (u7[1] ==
'&') && (u7[2] !=
'-'))
214 else if ((*u7 < 0x20) || (*u7 >= 0x7f))
252static char *
utf8_to_utf7(
const char *u8,
size_t u8len,
char **u7,
size_t *u7len)
265 unsigned char c = *u8;
310 for (
int i = 0; i < n; i++)
312 if ((u8[i] & 0xc0) != 0x80)
314 ch = (ch << 6) | (u8[i] & 0x3f);
316 if ((n > 1) && !(ch >> (n * 5 + 1)))
321 if ((ch < 0x20) || (ch >= 0x7f))
335 int pair1 = 0xd800 + (ch >> 10);
336 int pair2 = 0xdc00 + (ch & 0x3ff);
341 for (; k >= 0; k -= 6)
342 *p++ =
B64Chars[(pair1 >> k) & 0x3f];
343 b = (pair1 << (-k)) & 0x3f;
352 for (; k >= 0; k -= 6)
354 b = (ch << (-k)) & 0x3f;
const char * cc_charset(void)
Get the cached value of $charset.
Convenience wrapper for the core headers.
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
int mutt_ch_convert_string(char **ps, const char *from, const char *to, uint8_t flags)
Convert a string between encodings.
#define mutt_ch_is_utf8(str)
#define MUTT_ICONV_NO_FLAGS
No flags are set.
Convenience wrapper for the library headers.
void imap_utf_encode(bool unicode, char **s)
Encode email from local charset to UTF-8.
static char * utf8_to_utf7(const char *u8, size_t u8len, char **u7, size_t *u7len)
Convert data from UTF-8 to RFC2060's UTF-7.
void imap_utf_decode(bool unicode, char **s)
Decode email from UTF-8 to local charset.
static const char B64Chars[64]
Characters of the Base64 encoding.
static char * utf7_to_utf8(const char *u7, size_t u7len, char **u8, size_t *u8len)
Convert data from RFC2060's UTF-7 to UTF-8.
static const int Index64u[128]
Lookup table for Base64 encoding/decoding.