IOS 9.0 nsstring Kanji how to survive UTF8

Source: Internet
Author: User
<span id="Label3"></p><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px;"><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px;"><span style="font-family: Menlo; color: #703daa;">NSString<span style="font-family: Menlo;"> *str = <span style="color: #d12f1b;"><span style="font-family: Menlo;">@ " <span style="font-family: Heiti SC Light;">I am a good person <span style="font-family: Menlo; color: #d12f1b;">"<span style="font-family: Menlo;">;</span> </span> </span> </span></span> </span></span></p></p><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px;"><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px;">before turning this into a UTF8, we used</span></span></span><p style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px;"><p style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px;"></p></p><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo;"><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo;"><span style="color: #703daa;">NSString *STR3 = [str stringbyaddingpercentescapesusingencoding:</span></p></p><p style="font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo; color: #3d1d81;"><p style="font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo; color: #3d1d81;">nsutf8stringencoding];</p></p><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo;"><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo;">But in ios9, this method is Obsolete.</p></p><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo;"><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo;">Use the following method to turn</p></p><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo;"><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo;"></p></p><p style="font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo; color: #3d1d81;"><p style="font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo; color: #3d1d81;"><span style="color: #000000;"><span style="color: #703daa;">nsstring<span style="color: #000000;"> *str1 = [str stringbyaddingpercentencodingwithallowedcharacters<span style="color: #000000;">: [<span style="color: #703daa;">nscharacterset <span style="color: #000000;"> Urlqueryallowedcharacterset<span style="color: #000000;">]];</span> </span> </span> </span> </span> </span></span></p></p><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo;"><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo;"><br></p></p><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo;"><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo;">What if you want to turn into a " <span style="color: #d12f1b; font-family: ‘Heiti SC Light‘; font-size: 14px; line-height: 26px;">I'm a good person" string, don't worry about a way.</span></p></p><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo;"><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo;">Or is that the way we used to be</p></p><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo;"><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo;"></p></p><p style="font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo; color: #3d1d81;"><p style="font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo; color: #3d1d81;"><span style="color: #703daa;">NSString<span style="color: #000000;"> *str3 = [str1 stringbyreplacingpercentescapesusingencoding<span style="color: #000000;">: nsutf8stringencoding<span style="color: #000000;">];</span> </span> </span></span></p></p><p style="font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo; color: #3d1d81;"><p style="font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo; color: #3d1d81;"><span style="color: #000000;"><br></span></p></p><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo;"><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo;">iOS9 also abandoned this method now used</p></p><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo;"><p style="color: #333333; font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo;"></p></p><p style="font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo; color: #3d1d81;"><p style="font-size: 14px; line-height: 26px; margin-top: 0px; margin-bottom: 0px; font-family: Menlo; color: #3d1d81;"><span style="color: #703daa;">NSString<span style="color: #000000;"> *str2 = [str1 stringbyremovingpercentencoding<span style="color: #000000;">];</span> </span></span></p></p><p><p>IOS 9.0 nsstring Kanji how to survive UTF8</p></p></span>

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.