ios-Note character encoding

Source: Internet
Author: User

Today do video subtitles part, is the SRT format, get the string, in the decoding process jam half a day, is also drunk

The data obtained is available, converted to a string Leng no data,

After many studies have found their own mistakes,

Used to decode the way is UTF8, so used to

NSString *String = [[NSString alloc]initwithdata:data encoding:nsutf8stringencoding];

The result string is always empty and finally found not the data error but the decoding error.

The solution is as follows,

// GBK Encoding Nsstringencoding enc = cfstringconvertencodingtonsstringencoding (kcfstringencodinggb_18030_2000);             // decoding NSString *String = [[NSString alloc] Initwithdata:data Encoding:enc];

This will be done, the string is displayed.

ios-Note character encoding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.