AlanQuatermain / aqtoolkit

A toolkit consisting of a bunch of generally useful routines and extensions I wrote when putting together other projects.
http://blog.alanquatermain.net/code
BSD 3-Clause "New" or "Revised" License
785 stars 149 forks source link

Problem parsing XML with encoding "US-ASCII" in AQXMLparser #4

Open GerTeunis opened 14 years ago

GerTeunis commented 14 years ago

The parsing seems to keep starting over and over. Perhaps the US-ASCII isn't detected/used correctly. "US-ASCII is upwards-compatible with UTF-8 (an US-ASCII string is also a UTF-8 string, see [RFC 3629])"

When I manually change the encoding inside the xml to "utf-8" it seems to work okay.

GerTeunis commented 14 years ago

I've added a rather temporary/dirty fix by added the following lines of code to AQXMLParser.m (line 371 in __startDocument)

if ([[[NSString stringWithCString:encoding encoding:NSUTF8StringEncoding] lowercaseString] isEqualToString:@"us-ascii"]) { encoding = "utf-8"; }

I know; dirty but it works for the time being. There doesn't seem to be a good stricmp or strcmpi available?