IOS Unicode Character Processing

Source: Internet
Author: User


#define THEROWLENGTH 16

#define Unicodestart 9728-1
+ (NSString *) Replaceunicode: ( NSString *) Unicodestr {

NSString *tempstr1 = [unicodestr stringbyreplacingoccurrencesofstring:@ "\\u" withstring:@ "\\u"];

NSString *TEMPSTR2 = [tempStr1 stringbyreplacingoccurrencesofstring:@ "\" "withstring:@" \\\ ""];

NSString *TEMPSTR3 = [[@] "" STRINGBYAPPENDINGSTRING:TEMPSTR2] stringbyappendingstring:@ "" "];

NSData *tempdata = [TempStr3 datausingencoding:nsutf8stringencoding];

nsstring* returnstr = [Nspropertylistserialization propertylistfromdata:tempdata

Mutabilityoption:nspropertylistimmutable

Format:null

Errordescription:null];

NSLog (@ "Output =%@", returnstr);

return [Returnstr stringbyreplacingoccurrencesofstring:@ "\\r\\n" withstring:@ "\ n"];

}

-(void) Showunicodeicon

{

j = therowlength;

Dispatch_async (Dispatch_get_global_queue (dispatch_queue_priority_default, 0), ^{

Nstimer *timerrun = [Nstimer timerwithtimeinterval:3 target:self selector: @selector (timeshow) Userinfo:nil Repeats:YES ];

[[Nsrunloop Currentrunloop] Addtimer:timerrun formode:nsrunloopcommonmodes];

[[Nsrunloop Currentrunloop] run];

[[Nsrunloop Currentrunloop] rununtildate:[nsdate datewithtimeintervalsincenow:20.0]]; Main thread waits, but yields the main thread time slice, then returns after 10 seconds

});

}

-(void) timeshow

{

Nsmutablestring *stirn2= [nsmutablestring stringwithcapacity:0];

for (int i = 1; I <= J; i++) {

i = 1 adjustment at Unicodestart Place

[Stirn2 appendformat:@ "\\u%x", Unicodestart + i% therowlength + (Therowlength * (i/therowlength))];

NSLog (@ "The string is # #%@", stirn2);

NSString *unicodestringshow = [[self class] replaceunicode:stirn2];

if (i% Therowlength = = 0) {

NSLog (@ "The Unicode is%@", unicodestringshow);

Back to main thread

Dispatch_async (Dispatch_get_main_queue (), ^{

Refresh UI

_label.font = [Uifont fontwithname:@ "Helvetica" size:40.f];

_label.textalignment = Nstextalignmentleft;

_label.numberoflines = 0;//number of rows is set to 1, default line number is 1 when not set

[_label SizeToFit];

_label.text = [NSString stringwithstring:unicodestringshow];

});

}

NSLog (@ "The Unicode is%@", unicodestring);

if (i% Therowlength = 0 && (i!= 0)) {

Empty this string

[Stirn2 setstring:@ "];

NSLog (@ "The string is ===%@", stirn2);

}

}

J + + 16;

NSLog (@ "%@", @ "Timeshow");

}

Related Article

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.