简体   繁体   English

[NSString stringWithCString:变量编码:1]中的编码是什么; 或stringWithUTF8String

[英]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: 1NSASCIIStringEncoding ,不应将其作为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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM