• 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
searching a Unicode string in a text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

searching a Unicode string in a text


  • Subject: searching a Unicode string in a text
  • From: Arthur Clemens <email@hidden>
  • Date: Thu, 19 Sep 2002 23:38:51 +0200

I'm trying to read a file to find certain words and Unicode characters.
The English words give me no problem, only the Unicode characters I
cannot find using my method.

So I have a character that appears in the text as a filled circle with
a '1' inside. DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT ONE. It has
Unicode number 278A, according to the character palette.

To read the strings in the text I put the content of the text file in a
NSMutableAttributedString, and then pass chunks of the string to my
method. These chunks are delimited by a newline char:

characterDelimiterSet = [NSCharacterSet
characterSetWithCharactersInString:@"\n"]; // use only a newline as
delimiter

In my method findKeyword I have:

NSRange range = [string rangeOfString:@"\\u278a"];
NSLog(@"string = %@, length = %d, range.length = %d", string, [string
length], range.length);
if( range.location == 0 && range.length == [string length] ) {
NSLog(@"found");
returnString = [[[NSString alloc] initWithString:@"1"] autorelease];
return returnString;
}

This returns
"string = \\u278a, length = 1, range.length = 0"

So the string seems to get passed correctly, only the string
rangeOfString cannot handle the Unicode.
Should I use another method?

Arthur Clemens
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: searching a Unicode string in a text
      • From: Ondra Cada <email@hidden>
References: 
 >Re(2): Preferences (was: UI: "Direct manipulation" is in conflict with "Forgiveness") (From: Jens Bauer <email@hidden>)

  • Prev by Date: Re: Re(2): Preferences (was: UI: "Direct manipulation" is in conflict with "Forgiveness")
  • Next by Date: Re: Re(2): Preferences (was: UI: "Direct manipulation" is in conflict with "Forgiveness")
  • Previous by thread: Re: Re(2): Preferences (was: UI: "Direct manipulation" is in conflict with "Forgiveness")
  • Next by thread: Re: searching a Unicode string in a text
  • Index(es):
    • Date
    • Thread