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

Support for other encodings than UTF8 #19

Open
smic opened this issue Feb 8, 2012 · 2 comments
Open

Support for other encodings than UTF8 #19

smic opened this issue Feb 8, 2012 · 2 comments

Comments

@smic
Copy link

smic commented Feb 8, 2012

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);
             }
@schwa
Copy link
Member

schwa commented Apr 24, 2012

Please re-submit this as a pull request.

Thanks.

@bayfatih2000
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants