[英]what is encoding in [NSString stringWithCString: variable encoding:1]; or stringWithUTF8String
What does encoding:1 mean and what other values can be passed? encoding:1是什么意思,以及可以传递什么其他值? Please clarify arguments meaning, thanks. 请澄清论点的含义,谢谢。
- (void)enterInfo {
NSLog(@"What is the first name?");
char cstring[40];
scanf("%s", cstring);
firstName = [NSString stringWithCString:cstring encoding:1];
}
- (void)printInfo {
NSLog(@"First name: %@", firstName);
}
1
is NSASCIIStringEncoding
and should not be passed as 1
but like: 1
是NSASCIIStringEncoding
,不应将其作为1
传递,但应类似于:
firstName = [NSString stringWithCString:cstring encoding:NSASCIIStringEncoding];
You can find the full list of encoding in the NSString
documentation 您可以在NSString
文档中找到完整的编码列表
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.