unichar

How do I split a string with special characters into a NSMutableArray

青春壹個敷衍的年華 提交于 2020-01-02 05:14:12
问题 I'am trying to seperate a string with danish characters into a NSMutableArray. But something is not working. :( My code: NSString *danishString = @"æøå"; NSMutableArray *characters = [[NSMutableArray alloc] initWithCapacity:[danishString length]]; for (int i=0; i < [danishString length]; i++) { NSString *ichar = [NSString stringWithFormat:@"%c", [danishString characterAtIndex:i ]]; [characters addObject:ichar]; } If I do at NSLog on the danishString it works (returns æøå); But if I do a NSLog

Appending unichar to NSMutableString

二次信任 提交于 2020-01-02 02:24:07
问题 How do you append a unichar character to NSMutableString ? unichar c = 'T'; NSMutableString *s = [NSMutableString stringWithString:@"MyString"]; // want s to become "MyStringT" https://discussions.apple.com/thread/1679290 suggests: [s appendString:[NSString stringWithCharacters:&c length:1]]; Looks too long / complicated... 回答1: Use [NSString appendFormat:], so for above: [s appendFormat:@"%C", c]; Enjoy! 来源: https://stackoverflow.com/questions/29357205/appending-unichar-to-nsmutablestring

Question mark in place of font icon for some font codes

久未见 提交于 2019-12-24 07:14:10
问题 I have custom font icon TTF file downloaded to the device. I also have mappings for font icon name and its font code. A question mark is being displayed instead of font icon for some of the font code. The font code points are received from server in decimal number format. I am doing this to display font icon: unichar decimal = [iconMap.fontCode unsignedShortValue];//fontCode is an NSNumber NSString *charStr = [NSString stringWithFormat:@"%C", decimal]; [self.button setTitle:charStr forState

Converting Unichar to Int Problem

丶灬走出姿态 提交于 2019-12-08 17:41:34
问题 I've got a strange problem trying to convert from unichar to int: I have a String containing a few numbers, like @"12345" . This numbers I want to save individually, meaning I want 5 numbers, 1, 2, 3, ... . Now, while NSLog(@"Value: %C", [myString characterAtIndex:0]); returns Value: 1 This: NSLog(@"Value: %@", [NSNumber numberWithUnsignedChar:[myString characterAtIndex:0]]); returns Value: 49 I would really appreciate some help, Fabian 回答1: In the code above, you're getting exactly what you

Convert or Print CGPDFStringRef string

坚强是说给别人听的谎言 提交于 2019-12-07 11:55:08
问题 How to convert a CGPDFStringRef to unicode char? I have used CGPDFStringCopyTextString to get the string and then [string characterAtIndex:i] to cast to unichar, is this the right way? or is there any way to get the bytes of the string and convert to unicode directly? Need some guidance here. 回答1: NSString is capable of handling of unicode characters itself, you just need to convert the CGPDFString to NSString and further you can use it as follows: NSString *tempStr = (NSString *

Convert or Print CGPDFStringRef string

廉价感情. 提交于 2019-12-06 00:49:03
How to convert a CGPDFStringRef to unicode char? I have used CGPDFStringCopyTextString to get the string and then [string characterAtIndex:i] to cast to unichar, is this the right way? or is there any way to get the bytes of the string and convert to unicode directly? Need some guidance here. NSString is capable of handling of unicode characters itself, you just need to convert the CGPDFString to NSString and further you can use it as follows: NSString *tempStr = (NSString *)CGPDFStringCopyTextString(objectString); although UPT's answer is correct, it will produce a memory leak from the

How do I split a string with special characters into a NSMutableArray

随声附和 提交于 2019-12-05 15:41:56
I'am trying to seperate a string with danish characters into a NSMutableArray. But something is not working. :( My code: NSString *danishString = @"æøå"; NSMutableArray *characters = [[NSMutableArray alloc] initWithCapacity:[danishString length]]; for (int i=0; i < [danishString length]; i++) { NSString *ichar = [NSString stringWithFormat:@"%c", [danishString characterAtIndex:i ]]; [characters addObject:ichar]; } If I do at NSLog on the danishString it works (returns æøå); But if I do a NSLog on the characters (the array) I get some very stange characters - What is wrong? /Morten First of all,

Appending unichar to NSMutableString

家住魔仙堡 提交于 2019-12-05 04:58:24
How do you append a unichar character to NSMutableString ? unichar c = 'T'; NSMutableString *s = [NSMutableString stringWithString:@"MyString"]; // want s to become "MyStringT" https://discussions.apple.com/thread/1679290 suggests: [s appendString:[NSString stringWithCharacters:&c length:1]]; Looks too long / complicated... Use [NSString appendFormat:], so for above: [s appendFormat:@"%C", c]; Enjoy! 来源: https://stackoverflow.com/questions/29357205/appending-unichar-to-nsmutablestring