`

Convert UTF-8 encoded NSData to NSString,转载自stackoverflow

    博客分类:
  • IOS
阅读更多
If the data is not null-terminated, you should use -initWithData:encoding:
NSString* newStr = [[NSString alloc] initWithData:theData encoding:NSUTF8StringEncoding];

If the data is null-terminated, you should instead use -stringWithUTF8String: to avoid the extra \0 at the end.
NSString* newStr = [NSString stringWithUTF8String:[theData bytes]];

转载地址:http://stackoverflow.com/questions/2467844/convert-utf-8-encoded-nsdata-to-nsstring/2467856#2467856
分享到:
评论

相关推荐

    textfile.js:读写UTF-8编码的文本文件

    读写UTF-8编码的文本文件 使阅读,保存和编辑文本文件更加简单和更具描述性: 编码始终为UTF-8。...// Read UTF-8 encoded text file const content = await readTextFile ( "path/filename.txt" )

    convmv-1.15.tar.gz

    It is also possible to convert directories to UTF-8 which are already partly UTF-8 encoded. convmv is able to detect if certain files are UTF-8 encoded and will skip them by default. To turn this ...

    将utf-8字符写入文件java

    看到此链接,这可能对您有帮助。http://www.mkyong.com/java/how-to-write-utf-8-encoded-data-into-a-file-java/ [^]感谢--RA

    NSData+AESCrypt库

    + (NSData *)dataWithBase64EncodedString:(NSString *)string; - (id)initWithBase64EncodedString:(NSString *)string; - (NSString *)base64Encoding; - (NSString *)base64EncodingWithLineLength:(NSUInteger...

    Installing mini-xml along with a sample code

    Mini-XML supports reading of UTF-8 and UTF-16 and writing of UTF-8 encoded XML files and strings. Data is stored in a linked-list tree structure, preserving the XML data hierarchy, and arbitrary ...

    NSData+AESCrypt

    + (NSData *)dataWithBase64EncodedString:(NSString *)string; - (id)initWithBase64EncodedString:(NSString *)string; - (NSString *)base64Encoding; - (NSString *)base64EncodingWithLineLength:(NSUInteger...

    utf82hex:将utf8文本转换为utf8十六进制字符串的工具

    'e6bca2e5ad97' // Hex string representation of the unicode encoded in utf-8 > utf82hex . decode ( "e6bca2e5ad97" ) '漢字' 查看“ UTF-8(十六进制)”部分,并将其与输出进行比较以了解其工作原理。

    ExtDesigner1.1.1包含破解2011-03-18发布 (1 of 2)

    * Projects are properly UTF-8 encoded and preserve international Unicode characters xds-1.1.0 March 16th Enhancements * Save to Toolbox - save your components to the Toolbox for reuse across ...

    LuaUnicode icu-lua

    Either a UTF-8 encoded string can appear directly with 8-bit characters or you can use the \ddd syntax (note that ddd is a decimal number, unlike some other languages). However, there is no facility ...

    MicroWindows-Source-200606.zip

    MicroWindows <br>This README.txt in encoded in UTF-8. 本文件为UTF-8编码。 <br>MicroWindows是一套起源于1992年、名为ToyGUI的计划,后来重构为 1994年时所完成的样子。2006年时,我决定将原始码...

    AR-Self-Encoded Spread Spectrum

    AR-SESS AR-SESS AR-SESS AR-SESS AR-SESS AR-SESS AR-SESSAR-SESS AR-SESS AR-SESSAR-SESS AR-SESS AR-SESS

    DIRegEx 8.7.1 D4-XE10.1

    Unicode is supported via UTF-8 encoded strings: full substring capturing named subpatterns (Perl and Python syntax) case sensitive and insensitive matching greedy and non-greedy repetition ...

    DIRegEx 8.7.0 D4-XE10.1

    Unicode is supported via UTF-8 encoded strings: full substring capturing named subpatterns (Perl and Python syntax) case sensitive and insensitive matching greedy and non-greedy repetition ...

    Python发起请求提示UnicodeEncodeError错误代码解决方法

    Use body.encode(‘utf-8’) if you want to send it encoded in UTF-8. 解决: 对请求参数进行编码处理: 示例代码: import requests import json import re import pymysql from tool.Mysql_connect import ...

    javabase64-1.3.1

    Base64是网络上最常见的用于传输8Bit字节代码的编码方式之一。...在其他应用程序中,也常常需要把二进制数据编码为适合放在URL(包括隐藏表单域)中的形式。...String decoded = Base64.decode(encoded, "UTF-8");

    Perl-compatible Regular Expressions VC compile project

    The current implementation of PCRE (release 7.x) corresponds approximately with Perl 5.10, including support for UTF-8 encoded strings and Unicode general category properties. However, UTF-8 and ...

    Acoustic and Ultrasonic Detection With Radio-Frequency Encoded Fiber Laser Sensors

    Acoustic and Ultrasonic Detection With Radio-Frequency Encoded Fiber Laser Sensors

    teraterm-4.93

    After Kanji(receive) is set to EUC and UTF-8 string is displayed, new Kanji(Chinese character) may be properly shown when Kanji(receive) is set to UTF-8. When Kanji(receive) is set to UTF-8, ISO-2022-...

    jupyterlab-spreadsheet:用于查看电子表格的 JupyterLab 插件,例如 Excel .xls.xlsx 工作簿和 OpenOffice .ods 文件

    JupyterLab 电子表格 试试看! 这个插件为 JupyterLab 添加了一个简单的电子表格查看器。 jupyterlab-spreadsheet支持 XLS、XLSX、ODS 和 CSV 文件,并允许进行基本格式设置(例如单元格合并)。...

    DIRegEx v8.6.8 for D4-XE10 字符 匹配 文本编辑

    This includes support for UTF-8 encoded strings and Unicode general category properties. DIRegEx offers two regular expression algorithms with their corresponding wrapper classes for easy usage: ...

Global site tag (gtag.js) - Google Analytics