Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Support for other encodings than UTF8 #19

Open
smic opened this Issue · 2 comments

3 participants

Stephan Michels Jonathan Wight bayfatih2000
Stephan Michels

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);
             }
Jonathan Wight
Owner

Please re-submit this as a pull request.

Thanks.

bayfatih2000

How can I implement this code? I cannot understand. :((

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.