@@ -87,18 +87,20 @@ lossy: (bool)lossy; - (OFString*)OF_JSONRepresentationWithOptions: (int)options depth: (size_t)depth; @end -extern bool of_unicode_to_iso_8859_15(const of_unichar_t*, uint8_t*, size_t, - bool); -extern bool of_unicode_to_windows_1252(const of_unichar_t*, uint8_t*, size_t, - bool); -extern bool of_unicode_to_codepage_437(const of_unichar_t*, uint8_t*, size_t, - bool); -extern bool of_unicode_to_codepage_850(const of_unichar_t*, uint8_t*, size_t, - bool); +extern bool of_unicode_to_iso_8859_15(const of_unichar_t*, unsigned char*, + size_t, bool); +extern bool of_unicode_to_windows_1252(const of_unichar_t*, unsigned char*, + size_t, bool); +extern bool of_unicode_to_codepage_437(const of_unichar_t*, unsigned char*, + size_t, bool); +extern bool of_unicode_to_codepage_850(const of_unichar_t*, unsigned char*, + size_t, bool); +extern bool of_unicode_to_mac_roman(const of_unichar_t*, unsigned char*, + size_t, bool); /* References for static linking */ void _references_to_categories_of_OFString(void) { @@ -955,10 +957,12 @@ encoding = OF_STRING_ENCODING_ISO_8859_1; if ([contentType hasSuffix: @"charset=iso-8859-15"]) encoding = OF_STRING_ENCODING_ISO_8859_15; if ([contentType hasSuffix: @"charset=windows-1252"]) encoding = OF_STRING_ENCODING_WINDOWS_1252; + if ([contentType hasSuffix: @"charset=macintosh"]) + encoding = OF_STRING_ENCODING_MAC_ROMAN; } if (encoding == OF_STRING_ENCODING_AUTODETECT) encoding = OF_STRING_ENCODING_UTF_8; @@ -1066,11 +1070,11 @@ cString[i] = '?'; else @throw [OFInvalidEncodingException exception]; } else - cString[i] = (char)characters[i]; + cString[i] = (unsigned char)characters[i]; } cString[i] = '\0'; return length; @@ -1084,55 +1088,66 @@ cString[i] = '?'; else @throw [OFInvalidEncodingException exception]; } else - cString[i] = (uint8_t)characters[i]; + cString[i] = (unsigned char)characters[i]; } cString[i] = '\0'; return length; case OF_STRING_ENCODING_ISO_8859_15: if (length + 1 > maxLength) @throw [OFOutOfRangeException exception]; - if (!of_unicode_to_iso_8859_15(characters, (uint8_t*)cString, - length, lossy)) + if (!of_unicode_to_iso_8859_15(characters, + (unsigned char*)cString, length, lossy)) @throw [OFInvalidEncodingException exception]; cString[length] = '\0'; return length; case OF_STRING_ENCODING_WINDOWS_1252: if (length + 1 > maxLength) @throw [OFOutOfRangeException exception]; - if (!of_unicode_to_windows_1252(characters, (uint8_t*)cString, - length, lossy)) + if (!of_unicode_to_windows_1252(characters, + (unsigned char*)cString, length, lossy)) @throw [OFInvalidEncodingException exception]; cString[length] = '\0'; return length; case OF_STRING_ENCODING_CODEPAGE_437: if (length + 1 > maxLength) @throw [OFOutOfRangeException exception]; - if (!of_unicode_to_codepage_437(characters, (uint8_t*)cString, - length, lossy)) + if (!of_unicode_to_codepage_437(characters, + (unsigned char*)cString, length, lossy)) @throw [OFInvalidEncodingException exception]; cString[length] = '\0'; return length; case OF_STRING_ENCODING_CODEPAGE_850: if (length + 1 > maxLength) @throw [OFOutOfRangeException exception]; - if (!of_unicode_to_codepage_850(characters, (uint8_t*)cString, - length, lossy)) + if (!of_unicode_to_codepage_850(characters, + (unsigned char*)cString, length, lossy)) + @throw [OFInvalidEncodingException exception]; + + cString[length] = '\0'; + + return length; + case OF_STRING_ENCODING_MAC_ROMAN: + if (length + 1 > maxLength) + @throw [OFOutOfRangeException exception]; + + if (!of_unicode_to_mac_roman(characters, + (unsigned char*)cString, length, lossy)) @throw [OFInvalidEncodingException exception]; cString[length] = '\0'; return length; @@ -1192,10 +1207,11 @@ case OF_STRING_ENCODING_ISO_8859_1: case OF_STRING_ENCODING_ISO_8859_15: case OF_STRING_ENCODING_WINDOWS_1252: case OF_STRING_ENCODING_CODEPAGE_437: case OF_STRING_ENCODING_CODEPAGE_850: + case OF_STRING_ENCODING_MAC_ROMAN: cString = [object allocMemoryWithSize: length + 1]; [self OF_getCString: cString maxLength: length + 1 encoding: encoding @@ -1257,10 +1273,11 @@ case OF_STRING_ENCODING_ISO_8859_1: case OF_STRING_ENCODING_ISO_8859_15: case OF_STRING_ENCODING_WINDOWS_1252: case OF_STRING_ENCODING_CODEPAGE_437: case OF_STRING_ENCODING_CODEPAGE_850: + case OF_STRING_ENCODING_MAC_ROMAN: return [self length]; default: @throw [OFInvalidEncodingException exception]; } }