mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Use latin1 as default encoding.
Be strict about converting ascii to unicode ... check that it really is ascii. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19685 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
948b5dfb97
commit
ae3f5259a3
2 changed files with 32 additions and 1 deletions
|
@ -1,3 +1,10 @@
|
|||
2004-07-05 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/Unicode.m: GSToUnicode() be strict about converting ASCII
|
||||
to unicode.
|
||||
GetDefEncoding() don't override default (latin1) encoding to be
|
||||
ascii if we only have the return value of nl_langinfo() to go on.
|
||||
|
||||
2004-07-04 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSString.m: Added two new methods from MacOS-X
|
||||
|
|
|
@ -604,10 +604,17 @@ GetDefEncoding()
|
|||
#if HAVE_LANGINFO_CODESET
|
||||
/* Take it from the system locale information. */
|
||||
encoding = nl_langinfo(CODESET);
|
||||
/*
|
||||
* First handle the fallback response from nl_langinfo() ...
|
||||
* if we are getting the default value we can't assume that
|
||||
* the user has set anything up at all, so we must use the
|
||||
* OpenStep/GNUstep default encopding ... latin1, even though
|
||||
* the nl_langinfo() stuff would say default is ascii.
|
||||
*/
|
||||
if (strcmp(encoding, "ANSI_X3.4-1968") == 0 /* glibc */
|
||||
|| strcmp(encoding, "ISO_646.IRV:1983") == 0 /* glibc */
|
||||
|| strcmp(encoding, "646") == 0 /* Solaris NetBSD */)
|
||||
defEnc = NSASCIIStringEncoding;
|
||||
defEnc = NSISOLatin1StringEncoding;
|
||||
else if (strcmp(encoding, "EUC-JP") == 0 /* glibc */
|
||||
/* HP-UX IRIX OSF/1 Solaris NetBSD */
|
||||
|| strcmp(encoding, "eucJP") == 0
|
||||
|
@ -1281,6 +1288,23 @@ GSToUnicode(unichar **dst, unsigned int *size, const unsigned char *src,
|
|||
|
||||
case NSNonLossyASCIIStringEncoding:
|
||||
case NSASCIIStringEncoding:
|
||||
while (spos < slen)
|
||||
{
|
||||
unichar c = (unichar)((unc)src[spos++]);
|
||||
|
||||
if (c > 127)
|
||||
{
|
||||
result = NO; // Non-ascii data found in input.
|
||||
break;
|
||||
}
|
||||
if (dpos >= bsize)
|
||||
{
|
||||
GROW();
|
||||
}
|
||||
ptr[dpos++] = c;
|
||||
}
|
||||
break;
|
||||
|
||||
case NSISOLatin1StringEncoding:
|
||||
case NSUnicodeStringEncoding:
|
||||
while (spos < slen)
|
||||
|
|
Loading…
Reference in a new issue