views:

362

answers:

1

Hello all !

I am having difficulty with subj.

I have NSString text, contains "SLOVO", and i need that NSMutableString* currentRequest contain "%t%e%x%t%". I trying in cycle:

     [currentRequest appendFormat:@"%c%%", [text characterAtIndex:i]];

It's working fine, BUT if text contain for example "Rüdiger", i mean non latin symbols, then currentRequest contains full trash !

I've see decide is use (void)insertString:(NSString *)aString atIndex:(NSUInteger)anIndex but i think it is no right way. May be know right way ?

thanks.

+2  A: 

I may have misunderstood, but I think the issue with appendFormat is a mismatch between the %c format specifier and the return type of the characterAtIndex method.

Method characterAtIndex returns a unichar, whereas %c expects an 8-bit unsigned char. Use %C (uppercase C) instead in your format string.

Some Apple developer docs for reference:

martin clayton
thank you very much !
Sergey