discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GSString problem


From: Andreas Hoeschler
Subject: Re: GSString problem
Date: Mon, 5 Jul 2004 16:56:46 +0200

Hi,

after upgrading to a recent version of GNUstep my app throws the
following exception.

NSCharacterConversionException REASON: Can't get cStringLength from
Unicode string

I've had other reports of c-string related conversions failing when they
didn't before, and I suspect that:

2004-02-17 Bruno Haible <bruno@clisp.org>

* Source/Additions/Unicode.m (GetDefEncoding): Use the result of
nl_langinfo(CODESET) before falling back on ISO-8859-1.

is causing it by setting the c-string encoding to ASCII when it used to
be set to iso-8859-1. If so, setting the environment variable
GNUSTEP_STRING_ENCODING to NSISOLatin1StringEncoding should fix it.

Do we really ever want to set the c-string encoding to
NSASCIIStringEncoding instead of NSISOLatin1StringEncoding? (Especially
since parts of Unicode.m is pretending that ascii==iso-8859-1 anyway.)

I guess we do if the user wants to ...
ie if GNUSTEP_STRING_ENCODING specifies ASCII

However, I think it's probably sensible to use ISO-8859-1 if GNUSTEP_STRING_ENCODING
is not defined and nl_langinfo(CODESET) says ASCII

I wasn't aware that Unicode.m ever pretended ascii==iso-8859-1 ... I don't think it should.

Using NSISOLatin1StringEncoding instead of NSASCIIStringEncoding in Unicode.m did fix the problem for me.

if (defEnc == GSUndefinedEncoding)
{
/* Encoding not set */
#if HAVE_LANGINFO_CODESET
/* Take it from the system locale information. */
encoding = nl_langinfo(CODESET);
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; // <------------ this is better
...
}

Regards,

Andreas

reply via email to

[Prev in Thread] Current Thread [Next in Thread]