• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: rangeOfString & UTF8 - SOLVED
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rangeOfString & UTF8 - SOLVED


  • Subject: Re: rangeOfString & UTF8 - SOLVED
  • From: Steve Cronin <email@hidden>
  • Date: Sun, 04 Oct 2009 16:45:06 -0500

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 <email@hidden> 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:

[ccox@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;
}
[ccox@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 email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: rangeOfString & UTF8 - SOLVED
      • From: Alastair Houghton <email@hidden>
References: 
 >rangeOfString & UTF8 (From: Steve Cronin <email@hidden>)
 >Re: rangeOfString & UTF8 (From: Clark Cox <email@hidden>)

  • Prev by Date: Re: Checking whether a file is a genuine PDF file
  • Next by Date: iPhone NavController within TabBarController (nested table views)
  • Previous by thread: Re: rangeOfString & UTF8
  • Next by thread: Re: rangeOfString & UTF8 - SOLVED
  • Index(es):
    • Date
    • Thread