Problem with TouchXML and UTF-8

Discussion in 'iPhone/iPad Programming' started by dutchchilly, Jul 18, 2010.

  1. macrumors member

    Joined:
    Jun 29, 2009
    #1
    Hi,

    I'm trying to get RSS data from a 3rd party website.
    The header of the feed is:

    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!-- generator="FeedCreator 1.7.2" -->
    <rss version="2.0">
    
    The code was running fine until an article was added with the 'é' character in it.
    My log shows the message "Input is not proper UTF-8, indicate encoding".

    Is there a workaround for it, as I cannot change the header of the RSS feed?

    Thanks in advance

    Edit: Found it, I've should have used 'NSISOLatin1StringEncoding' for the encoding option. It works now.
     
  2. macrumors newbie

    Joined:
    Jul 24, 2010
    #2
    Hello.
    I am having the same issue.
    How exactly and where did you set NSISOLatin1StringEncoding option???

    Thanks!
     
  3. macrumors newbie

    Joined:
    Jul 24, 2010
    #3
    never mind. Solved it.
     
  4. macrumors 6502

    seepel

    Joined:
    Dec 22, 2009
    #4
    How did you solve it?
     
  5. thread starter macrumors member

    Joined:
    Jun 29, 2009
    #5
    CXMLDocument *rssParser = [[[CXMLDocument alloc] initWithContentsOfURL:url encoding:NSISOLatin1StringEncoding options:0 error:nil] autorelease];
     
  6. macrumors regular

    Joined:
    Jun 3, 2009
    #6
    I also had the same problem and here's how i solve it : first convert data to string, then using the string to build the CXMLDocument.

    Code:
    // assume 'data' is what you get from the web service
    NSString *s = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
    	
    CXMLDocument *document = [[[CXMLDocument alloc] initWithXMLString:s options:0 error:error] autorelease];
     

Share This Page