mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
String encoding fixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17917 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e723e30c14
commit
0627eb75aa
4 changed files with 36 additions and 13 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
Sat Oct 18 07:10:00 2003 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* 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 <bruno@clisp.org>
|
||||||
|
|
||||||
|
* Source/NSString.m (initWithContentsOfFile:, initWithContentsOfURL:):
|
||||||
|
Fix recognition of UTF-8 BOM.
|
||||||
|
|
||||||
Fri Oct 17 14:28:49 2003 Nicola Pero <n.pero@mi.flashnet.it>
|
Fri Oct 17 14:28:49 2003 Nicola Pero <n.pero@mi.flashnet.it>
|
||||||
|
|
||||||
* Source/GNUmakefile (LIBRARY_VAR): Unused variable removed.
|
* Source/GNUmakefile (LIBRARY_VAR): Unused variable removed.
|
||||||
|
|
|
@ -198,8 +198,7 @@
|
||||||
<p>
|
<p>
|
||||||
This is used to specify the default encoding for 8-bit
|
This is used to specify the default encoding for 8-bit
|
||||||
strings. It defaults to NSISOLatin1StringEncoding, but
|
strings. It defaults to NSISOLatin1StringEncoding, but
|
||||||
may be any of the 8-bit encodings supported by your system
|
may be any of the 8-bit encodings supported by your system.
|
||||||
(excluding multi-byte encodings).
|
|
||||||
</p>
|
</p>
|
||||||
</desc>
|
</desc>
|
||||||
<term>GNUSTEP_HOST_CPU</term>
|
<term>GNUSTEP_HOST_CPU</term>
|
||||||
|
|
|
@ -573,7 +573,8 @@ GetDefEncoding()
|
||||||
{
|
{
|
||||||
count = 0;
|
count = 0;
|
||||||
while (str_encoding_table[count].enc
|
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++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1321,7 +1321,7 @@ handle_printf_atsign (FILE *stream,
|
||||||
NSStringEncoding enc = _DefaultStringEncoding;
|
NSStringEncoding enc = _DefaultStringEncoding;
|
||||||
NSData *d;
|
NSData *d;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
const unichar *test;
|
const unsigned char *data_bytes;
|
||||||
|
|
||||||
d = [[NSDataClass alloc] initWithContentsOfFile: path];
|
d = [[NSDataClass alloc] initWithContentsOfFile: path];
|
||||||
if (d == nil)
|
if (d == nil)
|
||||||
|
@ -1336,15 +1336,20 @@ handle_printf_atsign (FILE *stream,
|
||||||
RELEASE(self);
|
RELEASE(self);
|
||||||
return @"";
|
return @"";
|
||||||
}
|
}
|
||||||
test = [d bytes];
|
data_bytes = [d bytes];
|
||||||
if ((test != NULL) && (len > 1))
|
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! */
|
/* somebody set up us the BOM! */
|
||||||
enc = NSUnicodeStringEncoding;
|
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;
|
enc = NSUTF8StringEncoding;
|
||||||
}
|
}
|
||||||
|
@ -1363,7 +1368,7 @@ handle_printf_atsign (FILE *stream,
|
||||||
NSStringEncoding enc = _DefaultStringEncoding;
|
NSStringEncoding enc = _DefaultStringEncoding;
|
||||||
NSData *d = [NSDataClass dataWithContentsOfURL: url];
|
NSData *d = [NSDataClass dataWithContentsOfURL: url];
|
||||||
unsigned int len = [d length];
|
unsigned int len = [d length];
|
||||||
const unichar *test;
|
const unsigned char *data_bytes;
|
||||||
|
|
||||||
if (d == nil)
|
if (d == nil)
|
||||||
{
|
{
|
||||||
|
@ -1376,14 +1381,19 @@ handle_printf_atsign (FILE *stream,
|
||||||
RELEASE(self);
|
RELEASE(self);
|
||||||
return @"";
|
return @"";
|
||||||
}
|
}
|
||||||
test = [d bytes];
|
data_bytes = [d bytes];
|
||||||
if ((test != NULL) && (len > 1))
|
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;
|
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;
|
enc = NSUTF8StringEncoding;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue