must add CHARSET=UTF-8 if non-ASCII character is found because default charset is not well-defined
git-svn-id: https://zeitsenke.de/svn/SyncEvolution/trunk@181 15ad00c4-1369-45f4-8270-35d70d36bdcd
This commit is contained in:
parent
46cd60c556
commit
6f6c575290
1 changed files with 14 additions and 1 deletions
|
@ -385,6 +385,10 @@ void VObject::fromNativeEncoding()
|
|||
// if necessary do quoted-printable encoding
|
||||
bool doquoted = !is_30 &&
|
||||
wcsstr(native, SYNC4J_LINEBREAK) != NULL;
|
||||
|
||||
// non-ASCII character encountered
|
||||
bool utf8 = false;
|
||||
|
||||
while ((curr = native[in]) != 0) {
|
||||
in++;
|
||||
switch (curr) {
|
||||
|
@ -408,8 +412,14 @@ void VObject::fromNativeEncoding()
|
|||
out++;
|
||||
break;
|
||||
default:
|
||||
bool currIsUTF8 = (unsigned char)curr >= 128;
|
||||
|
||||
if (currIsUTF8) {
|
||||
utf8 = true;
|
||||
}
|
||||
|
||||
if (doquoted &&
|
||||
(curr == '=' || (unsigned char)curr >= 128)) {
|
||||
(curr == '=' || currIsUTF8)) {
|
||||
// escape = and non-ASCII characters
|
||||
wsprintf(foreign + out, TEXT("=%02X"), (unsigned int)(unsigned char)curr);
|
||||
out += 3;
|
||||
|
@ -441,6 +451,9 @@ void VObject::fromNativeEncoding()
|
|||
// we have used quoted-printable encoding
|
||||
vprop->addParameter(TEXT("ENCODING"), TEXT("QUOTED-PRINTABLE"));
|
||||
}
|
||||
if (utf8 && !vprop->getParameterValue("CHARSET")) {
|
||||
vprop->addParameter("CHARSET", "UTF-8");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue