ios - NSAttributedString to NSString UTF-8 -


my code like:

nsdata *data = [nskeyedarchiver archiveddatawithrootobject:[textview textstorage]]; nsstring *text = [[nsstring alloc] initwithdata:data encoding:nsasciistringencoding]; [xml appendformat:@">%@", text];  

if have nsasciistringencoding string ok. when change nsasciistringencoding nsutf8stringencoding returns null.but need utf-8 because xml file i'm appending string in utf-8. way how that? thx reply.

if textview uitextview, , xml nsmutablestring, should able replace code with:

[xml appendstring: textview.text]; 

or if need > prefix:

[xml appendformat:@">%@", textview.text]; 

nsstring keep track of encodings. need worry encoding later when xml (store or send through web service). , can use xml.utf8string regular c-string in utf8 format.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -