TouchCode/TouchXML — Issue #19: Support for other encodings than UTF8
Author: smic
Created: 2012-02-08 12:11:50+00:00
State: open

Here is little patch to support other encodings than UTF8 for the features/ARC branch

@@ -98,7 +98,7 @@

- (id)initWithData:(NSData *)inData options:(NSUInteger)inOptions error:(NSError **)outError
{
- return [self initWithData:inData encoding:NSUTF8StringEncoding options:inOptions error:outError];
+ return [self initWithData:inData encoding:0 options:inOptions error:outError];
}

- (id)initWithData:(NSData *)inData encoding:(NSStringEncoding)encoding options:(NSUInteger)inOptions error:(NSError **)outError
@@ -126,7 +126,7 @@
{
CFStringEncoding cfenc = CFStringConvertNSStringEncodingToEncoding(encoding);
CFStringRef cfencstr = CFStringConvertEncodingToIANACharSetName(cfenc);
- const char *enc = CFStringGetCStringPtr(cfencstr, 0);
+ const char *enc = cfencstr != NULL ? CFStringGetCStringPtr(cfencstr, 0) : NULL;
theDoc = xmlReadMemory([inData bytes], [inData length], NULL, enc, XML_PARSE_RECOVER | XML_PARSE_NOWARNING);
}