discuss-gnustep
[Top][All Lists]
Advanced

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

Re: NSLog does only ASCII or UTF-8! Was: Unicode and GNUstep (more info)


From: Richard Frith-Macdonald
Subject: Re: NSLog does only ASCII or UTF-8! Was: Unicode and GNUstep (more info)
Date: Sat, 11 May 2002 19:08:34 +0100

On Saturday, May 11, 2002, at 06:33 PM, Pascal Bourguignon wrote:

cat delivers the same result. I then changed the encoding in the
preferences of Terminal.app to MacOS Roman and retried. cat and pico
did
now deliver the expected result. So far so good.

A good move.  If you're going to work only with  the terminal and from
Macintosh, that is.

Ok, Terminal.app is set to "MacOS Roman". I have rewritten my program to
just do

        NSLog(@"Höschler");


But if, like  it seems, you have Macintosh  encoded files and sources,
then you will need to use:

export GNUSTEP_STRING_ENCODING=NSMacOSRomanStringEncoding
./FBTest.app/FBTest

Here is somethinh i do not understand now.

bash-2.03$ export GNUSTEP_STRING_ENCODING=NSMacOSRomanStringEncoding
bash-2.03$ ./FBTest
May 11 17:00:34 FBTest[14036] H¬öschler

Somewhat  better isn't  it.  Now,  it  seems that  NSLog only  outputs
UTF-8, hence the 195 escape code before the 246 translated by Terminal
to a Macintosh ö.

Nope.  NSLog uses the default encoding normally, and only resorts to utf8
if the string being logged cannot be represented using the default encoding.



bash-2.03$ export GNUSTEP_STRING_ENCODING=

Use:

    unset  GNUSTEP_STRING_ENCODING

to remove an environment variable in bash.


bash-2.03$ ./FBTest
WARNING:  - encoding not supported.
NSISOLatin1StringEncoding set as default.
May 11 17:02:10 FBTest[14039] Höschler

I have expected to get "Höschler" while the encoding is set to
NSMacOSRomanStringEncoding. However, I get H¬öschler instead. When I
reset the encoding to its default I get Höschler. Weird!

Well, it seems that NSLog does not honor the  GNUSTEP_STRING_ENCODING.

Actually, it does.

Effectively, we find:

 --------------------------------------------------------------------
 static void
 _NSLog_standard_printf_handler (NSString* message)
 {
   NSData       *d;
   const char   *buf;
   unsigned     len;

   d = [message dataUsingEncoding: NSASCIIStringEncoding
         allowLossyConversion: NO];
   if (d == nil)
     {
       d = [message dataUsingEncoding: NSUTF8StringEncoding
         allowLossyConversion: NO];
     }
 --------------------------------------------------------------------

in NSLog.m.


That's an old version of GNUstep ... Andreas said he was using the latest
version from CVS, and the current version of NSLog() uses the default encoding.





reply via email to

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