searching a Unicode string in a text
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.