tags:

views:

16

answers:

1

hi all ,i just want to knw,is there any boundations in xml parsing with characters

like can we parse a word containing some characters like "frühe" containing "ü" "böser" containing "ö"

while i am parsing my xml,which is few different languages, some characters are like the above. and wen i saw in console, it get interpted,exaactly wen it reacher "ü" becoz at console it prints "fr"

so can someone provide me some ideas about this thing

regards shishir

+1  A: 

If you are using the standard NSXmlParser class and the XML file has the correct encoding= attribute then you shouldn't have anything to worry about. The console output probably isn't unicode-aware so it is interpreting the multi-byte UTF-8 characters literally. Try showing the parsed text in a UIAlertView or some other UI element and see if you still have problems.

Mike Weller
thanks for the reply mike...yes i am using NSxmlParser,can u tell me,wat should be the correct encoding attribute for my xml???regards
shishir.bobby
It depends on the encoding of the file. <xml version="1.0" encoding="utf-8" /> is probably what you need. But I think NSXMLParser will already assume UTF-8 and parse the text correctly. It's just the that the console isn't handling unicode text properly.
Mike Weller
actually i m working on live xml,so i just saw that xml,which is having "<?xml version="1.0"?>" this.here i need to add "encoding="utf-8"" right??regards
shishir.bobby
If you don't control the XML then don't bother. NSXmlParser will probably assume utf-8 by default.
Mike Weller
than how can i overcome this problem.apart from dis special character problem,i cant c any other problem in parsing my xml......regards
shishir.bobby
Try displaying the text in the application's UI rather than through NSLog. I think the reason the character is not being displayed properly is just because the debugger console does not handle unicode properly.
Mike Weller
thanks mike,its started working now.thanks a lot
shishir.bobby