104{
105 static const char hex[] = "0123456789ABCDEF";
106 char *s0 = res;
107
108 memcpy(res, "=?", 2);
109 res += 2;
110 memcpy(res, tocode, strlen(tocode));
111 res += strlen(tocode);
112 memcpy(res, "?Q?", 3);
113 res += 3;
114 while (srclen--)
115 {
116 unsigned char c = *src++;
117 if (c == ' ')
118 {
119 *res++ = '_';
120 }
121 else if ((c >= 0x7f) || (c < 0x20) || (c ==
'_') || strchr(
MimeSpecials, c))
122 {
123 *res++ = '=';
124 *res++ = hex[(c & 0xf0) >> 4];
125 *res++ = hex[c & 0x0f];
126 }
127 else
128 {
129 *res++ = c;
130 }
131 }
132 memcpy(res, "?=", 2);
133 res += 2;
134 return res - s0;
135}
const char MimeSpecials[]
Characters that need special treatment in MIME.