IOS ASC Code Replacement

Source: Internet
Author: User

-(void) Click: (UIButton *) btn

{

nsstring *teststr = @ " learning > and congruent ";

nsstringencoding encoding2 = nsutf8stringencoding;

TESTSTR = [Teststr stringbyreplacingoccurrencesofstring:@ "\ t" withstring:@ ""];

TESTSTR = [Teststr stringbyreplacingoccurrencesofstring:@ "\x15" withstring:@ "" ];

TESTSTR = [Teststr stringbytrimmingcharactersinset: [nscharacterset controlcharacterset]];

TESTSTR = [Teststr stringbytrimmingcharactersinset: [nscharacterset controlcharacterset ]];

TESTSTR = [Teststr stringbytrimmingcharactersinset: [nscharacterset illegalcharacterset]];

TESTSTR = [Teststr stringbytrimmingcharactersinset: [nscharacterset symbolcharacterset] ];

TESTSTR = [Teststr stringbytrimmingcharactersinset: [nscharacterset nonbasecharacterset ]];

TESTSTR = [Teststr stringbytrimmingcharactersinset: [nscharacterset Whitespaceandnewlinecharacterset]];

nsmutablestring *newstr = [[nsmutablestring alloc]initwithcapacity:1 ];

for (int i = 0; i < [teststr length]; i++) {

Unichar c = [teststr characteratindex: i];

if(c>=0 && c<=)

{

continue;

}

[Newstr appendString: [nsstring stringwithformat:@ "%@", [Teststr Substringwithrange:nsmakerange(i, 1) ]];

int Bytesleng = [[Teststr substringwithrange:nsmakerange(i, 1)] Lengthofbytesusingencoding: encoding2];

NSLog(@ "teststr[%d]=%@ =%d,%d", I, [Teststr substringwithrange:nsmakerange(i, 1 )], C, Bytesleng);

}

NSLog(@ "%@=%d,%@=%d", Teststr, [teststr length], newstr, [newstr length]);

}

IOS ASC Code Replacement

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.