Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special characters and accents #15

Open
lfarah opened this issue Jul 22, 2014 · 4 comments
Open

Special characters and accents #15

lfarah opened this issue Jul 22, 2014 · 4 comments

Comments

@lfarah
Copy link

lfarah commented Jul 22, 2014

How do I parse xml's with accents?

@nicklockwood
Copy link
Owner

NSStrings are Unicode aware, so it should just work. If it doesn't, it may be that the encoding of the XML isn't UTF8, in which case decide it as a string with the correct encoding first, then pass it to XMLDictionary.

@lfarah
Copy link
Author

lfarah commented Jul 22, 2014

http://sistemas.ideastek.com.br/cnordeste/classificacao.xml?grupo=A
Is there something wrong with this XML?
I read something about appending strings on
-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{

@robertbarclay
Copy link

We just ran into a similar issue when parsing an XML server response with user generated data. When it hit a name that contained what I would guess was an accent mark, or other unicode character (Â is what rendered in our website browser page in chrome for that name). What happened is it appeared to have silently failed, exiting out of parsing all the remaining child elements of an element. The first 2 elements parsed, and when it hit the third, containing the element with the Unicode character, it stopped, skipping the remaining elements. The rest of the XML was parsed correctly. We have a library on android that handled it fine, but it failed miserably using this library.

It would be nice if it encounters that scenario, that we get some sort or NSError response. I've looked through the project code, but found no clear way errors are being handled if it encounters invalid characters, or NSXMLParser encounters an error. There are delegate methods for error handling, but they appear to not be implemented. I'd be happy to add it if you need. It may be that there is a problem with NSXMLParser, just not sure at this point, but it does give credence to the lfarah's request of handling real world Unicode problems. We were able to go in and remove the offending character to make our systems working, but that does not bode well for real world issues.

@CrazyGoose
Copy link

Issues with ' apostrophe.
Content = "you're";

The quote " works
Content = "you"re";

  • (NSString *)XMLEncodedString
    {
    return [[[[[self stringByReplacingOccurrencesOfString:@"&" withString:@"&"]
    stringByReplacingOccurrencesOfString:@"<" withString:@"<"]
    stringByReplacingOccurrencesOfString:@">" withString:@">"]
    stringByReplacingOccurrencesOfString:@""" withString:@"""]
    stringByReplacingOccurrencesOfString:@"'" withString:@"'"];

}

Not sure why this isnt working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants