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

How to read a looped string into another bigger string in C


I am trying to read one array over and over into another bigger array/string. What have I done wrong? I get the error message Thread1: signal SIGABRT??

Global RegEx Replace Function to Create Html from Square Brackets

.net regex vb.net global ektron

I have some existing code that looks something like this:

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.