iphone; UTF strings from xml

Hi there I have been trying to read an xml file with UTF strings, and am stuck with trying to convert them. My scenario

  1. Reading xml file from the internet - at times, the xml file contains unicode
  2. The files read ok, displays ok in the browser
  3. But when i try to display them - instead of the unicode characters i see ascii converted, something like & #54620;& #54620; [ i added space so that it does'nt display UTF in the post ]
  4. I tried to ocnvert them into UTF8String using [NSString stringWithUTF8String:[description UTF8String]], but did'nt work

What am i missing here?

edit: If i can understand how to convert a string & #2310;& #2306;& #2358;& #2367;& #2325; & #2313; (ofcourse without the spaces after the &) into its respective UTF symbols (in this case - hindi) - it would be a good start

edit: Sample xml content description="ख त" which i would like to convert to UTF characters, i could not find any function to do this conversion



Presumably you're reading that XML into an NSData object; it looks like you're converting it to a string somewhere, in description. Try this approach:

NSData *response = [self getXMLData];
NSString *content = [[NSString alloc]  initWithBytes:[response bytes]
   length:[response length] encoding: NSUTF8StringEncoding];

that should get you a good string with properly formed characters.

Need Your Help

AS3: setChildIndex of targetSection + “_mc” to FRONT / accessing buttons on alpha:0 MC

actionscript-3 flash flash-cs5

I'm currently making a customisation app in Flash CS5 using AS3 & Greensock's TimelineMax.

How can I interconnect a Node.js Application server and a LAMP stack?

php mysql apache node.js lamp

My current web-application requires a LAMP stack and a Node.js WebSocket server to operate. Interaction between the MySQL database and the Node.js webserver is absolutely critical.

ExpressionEngine (CMS) with SQLite

sqlite integration expressionengine

Has anyone out there hacked up ExpressionEngine (CMS) to work with SQLite? If so, any good tips or guides on how to do so?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.