你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> IOS中的編碼格式—char*漢字轉為NSString*

IOS中的編碼格式—char*漢字轉為NSString*

編輯:IOS開發綜合
char* 轉為NSString* NSStringEncoding enc = CFStringConvertEncodingToNSStringEncoding (kCFStringEncodingGB_18030_2000); char* c_test = "先先先"; int nLen = strlen(c_test); NSString* str = [[NSString alloc]initWithBytes:c_test length:nLen encoding:enc ];   創建一個mac os的工程,加入代碼: [cpp] view plaincopy  const NSStringEncoding *encodings = [NSString availableStringEncodings];              NSMutableString *str = [[NSMutableString alloc] init];              NSStringEncoding encoding;              while ((encoding = *encodings++) != 0)       {                      [str appendFormat: @"%@ === %li\n", [NSString localizedNameOfStringEncoding:encoding], encoding];       }       NSLog(@"%@",str);     得到: Western (Mac OS Roman) === 30 Japanese (Mac OS) === 2147483649 Traditional Chinese (Mac OS) === 2147483650 Korean (Mac OS) === 2147483651 Arabic (Mac OS) === 2147483652 Hebrew (Mac OS) === 2147483653 Greek (Mac OS) === 2147483654 Cyrillic (Mac OS) === 2147483655 Devanagari (Mac OS) === 2147483657 Gurmukhi (Mac OS) === 2147483658 Gujarati (Mac OS) === 2147483659 Thai (Mac OS) === 2147483669 Simplified Chinese (Mac OS) === 2147483673 Tibetan (Mac OS) === 2147483674 Central European (Mac OS) === 2147483677 Symbol (Mac OS) === 6 Dingbats (Mac OS) === 2147483682 Turkish (Mac OS) === 2147483683 Croatian (Mac OS) === 2147483684 Icelandic (Mac OS) === 2147483685 Romanian (Mac OS) === 2147483686 Celtic (Mac OS) === 2147483687 Gaelic (Mac OS) === 2147483688 Keyboard Symbols (Mac OS) === 2147483689 Farsi (Mac OS) === 2147483788 Cyrillic (Mac OS Ukrainian) === 2147483800 Inuit (Mac OS) === 2147483884 Unicode (UTF-16) === 10 Unicode (UTF-7) === 2214592768 Unicode (UTF-8) === 4 Unicode (UTF-32) === 2348810496 Unicode (UTF-16BE) === 2415919360 Unicode (UTF-16LE) === 2483028224 Unicode (UTF-32BE) === 2550137088 Unicode (UTF-32LE) === 2617245952 Western (ISO Latin 1) === 5 Central European (ISO Latin 2) === 9 Western (ISO Latin 3) === 2147484163 Central European (ISO Latin 4) === 2147484164 Cyrillic (ISO 8859-5) === 2147484165 Arabic (ISO 8859-6) === 2147484166 Greek (ISO 8859-7) === 2147484167 Hebrew (ISO 8859-8) === 2147484168 Turkish (ISO Latin 5) === 2147484169 Nordic (ISO Latin 6) === 2147484170 Thai (ISO 8859-11) === 2147484171 Baltic (ISO Latin 7) === 2147484173 Celtic (ISO Latin 8) === 2147484174 Western (ISO Latin 9) === 2147484175 Romanian (ISO Latin 10) === 2147484176 Latin-US (DOS) === 2147484672 Greek (DOS) === 2147484677 Baltic (DOS) === 2147484678 Western (DOS Latin 1) === 2147484688 Greek (DOS Greek 1) === 2147484689 Central European (DOS Latin 2) === 2147484690 Cyrillic (DOS) === 2147484691 Turkish (DOS) === 2147484692 Portuguese (DOS) === 2147484693 Icelandic (DOS) === 2147484694 Hebrew (DOS) === 2147484695 Canadian French (DOS) === 2147484696 Arabic (DOS) === 2147484697 Nordic (DOS) === 2147484698 Russian (DOS) === 2147484699 Greek (DOS Greek 2) === 2147484700 Thai (Windows, DOS) === 2147484701 Japanese (Windows, DOS) === 8 Simplified Chinese (Windows, DOS) === 2147484705 Korean (Windows, DOS) === 2147484706 Traditional Chinese (Windows, DOS) === 2147484707 Western (Windows Latin 1) === 12 Central European (Windows Latin 2) === 15 Cyrillic (Windows) === 11 Greek (Windows) === 13 Turkish (Windows Latin 5) === 14 Hebrew (Windows) === 2147484933 Arabic (Windows) === 2147484934 Baltic (Windows) === 2147484935 Vietnamese (Windows) === 2147484936 Western (ASCII) === 1 Japanese (Shift JIS X0213) === 2147485224 Chinese (GBK) === 2147485233 Chinese (GB 18030) === 2147485234 Japanese (ISO 2022-JP) === 21 Japanese (ISO 2022-JP-2) === 2147485729 Japanese (ISO 2022-JP-1) === 2147485730 Chinese (ISO 2022-CN) === 2147485744 Korean (ISO 2022-KR) === 2147485760 Japanese (EUC) === 3 Simplified Chinese (GB 2312) === 2147486000 Traditional Chinese (EUC) === 2147486001 Korean (EUC) === 2147486016 Japanese (Shift JIS) === 2147486209 Cyrillic (KOI8-R) === 2147486210 Traditional Chinese (Big 5) === 2147486211 Western (Mac Mail) === 2147486212 Simplified Chinese (HZ GB 2312) === 2147486213 Traditional Chinese (Big 5 HKSCS) === 2147486214 Ukrainian (KOI8-U) === 2147486216 Traditional Chinese (Big 5-E) === 2147486217 Western (NextStep) === 2 Non-lossy ASCII === 7 Western (EBCDIC Latin Core) === 2147486721 Western (EBCDIC Latin 1) === 2147486722  
  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved