Re: rangeOfString UTF8 - SOLVED

2009-10-05 Thread Alastair Houghton

On 4 Oct 2009, at 22:45, Steve Cronin wrote:

I had managed to convince myself that there was something about the  
utf8 umlats and all that I wasn't understanding …


FWIW, NSString always acts as if the string is represented in UTF-16  
(even if the underlying representation is something else), so thinking  
about UTF-8 is only ever going to confuse you.


Kind regards,

Alastair.

--
http://alastairs-place.net



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: rangeOfString UTF8 - SOLVED

2009-10-04 Thread Steve Cronin

Clark;

OK thanks for the whack on the head…

I had managed to convince myself that there was something about the  
utf8 umlats and all that I wasn't understanding …


No the problem was simply that there was a trailing space at the end  
of tString - 'Geschäftsführer (CEO) '


Thanks for your time!
Steve

On Oct 4, 2009, at 4:17 PM, Clark Cox wrote:

On Sun, Oct 4, 2009 at 1:48 PM, Steve Cronin steve_cro...@mac.com  
wrote:

Folks;

 (thePhrase) :  Geschäftsführer (CEO):

 (tString):  Geschäftsführer (CEO)

Both
   curPos = [thePhrase rangeOfString: tString
options:NSCaseInsensitiveSearch].location;

AND

   NSLocale *tLocale = [[[NSLocale alloc]
initWithLocaleIdentifier:@de_DE] autorelease];
   curPos = [thePhrase rangeOfString: tString
options:NSCaseInsensitiveSearch range:NSMakeRange(0, [thePhrase  
length])

locale:tLocale].location;

yield curPos == NSNotFound

Here's some printout from the console:
Printing description of thePhrase:
Gesch\u00e4ftsf\u00fchrer (CEO):

Printing description of tString:
Gesch\u00e4ftsf\u00fchrer (CEO)

What am I not understanding here?


Something else must be going on. I've just tried to replicate your
situation, and had no problems:

[c...@ccox-shiny:~]% cat test.m
#import Foundation/Foundation.h


int main() {
   NSString*thePhrase  = @Geschäftsführer (CEO):;
   NSString*tString= @Geschäftsführer (CEO);

   NSRange range   = [thePhrase rangeOfString: tString
options: NSCaseInsensitiveSearch];

   NSLog(@thePhrase   = \%...@\, thePhrase);
   NSLog(@tString = \%...@\, tString);
   NSLog(@range   = %@, NSStringFromRange(range));

   return 0;
}
[c...@ccox-shiny:~]% cc test.m -framework Foundation -fobjc-gc  ./ 
a.out
2009-10-04 14:17:04.981 a.out[7705:903] thePhrase   =  
Geschäftsführer (CEO):
2009-10-04 14:17:04.983 a.out[7705:903] tString =  
Geschäftsführer (CEO)

2009-10-04 14:17:04.983 a.out[7705:903] range   = {0, 21}




--
Clark S. Cox III
clarkc...@gmail.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com