diff --git a/ChangeLog b/ChangeLog index 00a94f6ec..d1e72ef15 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Sat Oct 18 07:10:00 2003 Richard Frith-Macdonald + + * Source/Additions/Unicode.m: Allow GNUSTEP_STRING_ENCODING to give + any supported iconv name in additiuon to OpenStep names. Make check + case insensitive. + Documentation/Base.gsdoc: Remove obsolete comment that + GNUSTEP_STRING_ENCODING may not specify a mu7ltibyte encoding. + +2003-10-16 Bruno Haible + + * Source/NSString.m (initWithContentsOfFile:, initWithContentsOfURL:): + Fix recognition of UTF-8 BOM. + Fri Oct 17 14:28:49 2003 Nicola Pero * Source/GNUmakefile (LIBRARY_VAR): Unused variable removed. diff --git a/Documentation/Base.gsdoc b/Documentation/Base.gsdoc index 07d99a30d..41076de6e 100644 --- a/Documentation/Base.gsdoc +++ b/Documentation/Base.gsdoc @@ -198,8 +198,7 @@

This is used to specify the default encoding for 8-bit strings. It defaults to NSISOLatin1StringEncoding, but - may be any of the 8-bit encodings supported by your system - (excluding multi-byte encodings). + may be any of the 8-bit encodings supported by your system.

GNUSTEP_HOST_CPU diff --git a/Source/Additions/Unicode.m b/Source/Additions/Unicode.m index 9e460315c..ffc817129 100644 --- a/Source/Additions/Unicode.m +++ b/Source/Additions/Unicode.m @@ -573,7 +573,8 @@ GetDefEncoding() { count = 0; while (str_encoding_table[count].enc - && strcmp(str_encoding_table[count].ename, encoding)) + && strcasecmp(str_encoding_table[count].ename, encoding) + && strcasecmp(str_encoding_table[count].iconv, encoding)) { count++; } diff --git a/Source/NSString.m b/Source/NSString.m index db0271ffb..495a435d8 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -1321,7 +1321,7 @@ handle_printf_atsign (FILE *stream, NSStringEncoding enc = _DefaultStringEncoding; NSData *d; unsigned int len; - const unichar *test; + const unsigned char *data_bytes; d = [[NSDataClass alloc] initWithContentsOfFile: path]; if (d == nil) @@ -1336,15 +1336,20 @@ handle_printf_atsign (FILE *stream, RELEASE(self); return @""; } - test = [d bytes]; - if ((test != NULL) && (len > 1)) + data_bytes = [d bytes]; + if ((data_bytes != NULL) && (len >= 2)) { - if ((test[0] == byteOrderMark) || (test[0] == byteOrderMarkSwapped)) + const unichar *data_ucs2chars = (const unichar *) data_bytes; + if ((data_ucs2chars[0] == byteOrderMark) + || (data_ucs2chars[0] == byteOrderMarkSwapped)) { /* somebody set up us the BOM! */ enc = NSUnicodeStringEncoding; } - else if (len > 2 && test[0] == 0xEF && test[1] == 0xBB && test[2] == 0xBF) + else if (len >= 3 + && data_bytes[0] == 0xEF + && data_bytes[1] == 0xBB + && data_bytes[2] == 0xBF) { enc = NSUTF8StringEncoding; } @@ -1363,7 +1368,7 @@ handle_printf_atsign (FILE *stream, NSStringEncoding enc = _DefaultStringEncoding; NSData *d = [NSDataClass dataWithContentsOfURL: url]; unsigned int len = [d length]; - const unichar *test; + const unsigned char *data_bytes; if (d == nil) { @@ -1376,14 +1381,19 @@ handle_printf_atsign (FILE *stream, RELEASE(self); return @""; } - test = [d bytes]; - if ((test != NULL) && (len > 1)) + data_bytes = [d bytes]; + if ((data_bytes != NULL) && (len >= 2)) { - if ((test[0] == byteOrderMark) || (test[0] == byteOrderMarkSwapped)) + const unichar *data_ucs2chars = (const unichar *) data_bytes; + if ((data_ucs2chars[0] == byteOrderMark) + || (data_ucs2chars[0] == byteOrderMarkSwapped)) { enc = NSUnicodeStringEncoding; } - else if (len > 2 && test[0] == 0xEF && test[1] == 0xBB && test[2] == 0xBF) + else if (len >= 3 + && data_bytes[0] == 0xEF + && data_bytes[1] == 0xBB + && data_bytes[2] == 0xBF) { enc = NSUTF8StringEncoding; }