diff options
author | 2014-04-04 10:47:25 -0700 | |
---|---|---|
committer | 2014-04-04 10:47:38 -0700 | |
commit | 59e0f04a251e47781ff4d6d5db8d0b6ebe5a92ce (patch) | |
tree | 4ac84b06d7733c66f3a5b7e3809b74d6284caf69 /src/core | |
parent | 79714c842a8480cf12823d98d15025f274255147 (diff) |
Fixed #671: workaround bad message encoding
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/basetypes/MCString.cc | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/core/basetypes/MCString.cc b/src/core/basetypes/MCString.cc index 3f0338db..3068bc18 100644 --- a/src/core/basetypes/MCString.cc +++ b/src/core/basetypes/MCString.cc @@ -1138,7 +1138,16 @@ void String::appendBytes(const char * bytes, unsigned int length, const char * c if (cfStr != NULL) { CFDataRef data = CFStringCreateExternalRepresentation(NULL, cfStr, kCFStringEncodingUTF16LE, '_'); if (data != NULL) { - appendCharactersLength((const UChar *) CFDataGetBytePtr(data), (unsigned int) CFDataGetLength(data) / 2); + UChar * fixedData = (UChar *) malloc(CFDataGetLength(data)); + memcpy(fixedData, CFDataGetBytePtr(data), CFDataGetLength(data)); + unsigned int length = (unsigned int) CFDataGetLength(data) / 2; + for(int32_t i = 0 ; i < length ; i ++) { + if (fixedData[i] == 0) { + fixedData[i] = ' '; + } + } + appendCharactersLength(fixedData, length); + free(fixedData); CFRelease(data); } CFRelease(cfStr); |