discuss-gnustep
[Top][All Lists]
Advanced

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

Re: NSString and encodings: possible bug


From: Richard Frith-Macdonald
Subject: Re: NSString and encodings: possible bug
Date: Thu, 24 Mar 2005 07:08:57 +0000

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2005-03-24 02:06:23 +0000 Wolfgang Sourdeau <Wolfgang@Contre.COM> wrote:

Hi all,


 From what I understand, NSString is supposed to abstract the encoding so
that application can use them in conjunctions with strings of another
encoding. (This assumption is based on the fact that all the
representations of those strings are converted before being shown).

However, yesterday, I wanted to initialize some strings with the
NSUnicodeStringEncoding but they could not compare against equivalent
ASCII-encoded string, although the text was the same. So, should I report
this as a bug or is this the expected behaviour?

Sample code would be useful ... from your description it is not clear what
you are doing.

   unichar ubuf[2];
   NSString *ascii;
   NSString *unicode;

   ubuf[0] = (unichar)'a';
   ubuf[1] = (unichar)'b';

   ascii = [[NSString alloc] initWithData: [NSData dataWithBytes: "ab"
length: 2] encoding: NSASCIIStringEncoding];
   unicode = [[NSString alloc] initWithData: [NSData dataWithBytes: ubuf
length: 4] encoding: NSUnicodeStringEncoding];
   NSLog(@"Comparison: %d", [ascii isEqual: unicode]);

Should print out the meassage 'Comparison: 1'

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using the GPG bundle for GNUMail

iD8DBQFCQmeJE6AJp3nmKIkRAuaIAJ49MDO+uX0z8qX4jXN79n8cqDLD/ACfQLOb
wftngCnqJ1YhFgdJ6fJblGo=
=2MqN
-----END PGP SIGNATURE-----





reply via email to

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