objective c - NSXMLParser with UTF8 Data -


I am trying to understand this and really appreciate any help.

I am trying to parse a UTF 8 string with NSXMLParser but this will not work.

This is my string

& lt ;? Xml version = "1.0" encoding = "UTF-8" & gt; & Lt; Host & gt; & Lt; Type & gt; Mac & lt; / Type & gt; & Lt; Harbor & gt; 62,181 & lt; / Port & gt; & Lt; Address & gt; 192.168.1.159 & lt; / Address & gt; & Lt; Host name & gt; % Of Samuel

and parsing code here

  - (zero)   

) pars : (NSString *) XMLEncodedString withLength: (int) l_length {#ifndef NDEBUG NSLog (@ "Lookup%%", XMLEncodedString); #endifdsdata * Data = [XMlencodedString DataSetting Encoding: NSUTF8StringEncoding]; NSXMLPers * Parser = [[NSXMLA Parser Allocus] Initvatadata Data]; [Parser set deliaget: self]; // Parser calls methods in this class [parser sethold process namespace: no]; // We do not care about namespaces [Parser Settlement ReportPassprint: No]; // [parser setShoulderSpecialExactents: No]; // We just want data, no other stuff [parsing pars]; // Parsing that data. [Parser release]; }

XMLEncodedString is designed like this

  - (zero) checkoffer receipt {// NSLog (@ "Waiting for the listener: recvfrom. .. \ n "); Addr_len = the size of their_addr; If ((numbytes = recvfrom (sockfd, buf, MAXBUFLEN-1, 0, (struct sockaddr *) and amp; their_addr, and addr_len)) == -1) {perror ("recvfrom"); Return; } Buff [numbytes] = '\ 0'; NSString * string = [[NSString alloc] initWithUTF8String: buf]; [Self pars: string with lailenda: nibbite]; [String release]; }  

My problem is coming from Unicode character 'Right Single Quotation Mark' (U + 2019) which is in my string and I am getting this error:

< P> 2010-07-19 17: 13: 35.734 Swipesendorom 2 [34354: 4233] Error domain = NSXMLParserErrorDomain code = 73 "operation could not be completed. (NSXMLParserErrorDomain Error 73.)" 2010-07-19 17:13: 35.736 SwypeSendForMac2 [34354: 4233] error domain = NSXMLParserErrorDomain code = 76 "the operation could not be completed. (NSXMLParserErrorDomain error 76.)"

your key Kshn the method call xml to try to change any problem characters like this:

NSString * final = [connRespStr stringByReplacingOccurrencesOfString: @ "& Amp; " String with: @ "and"];

The above line changes all ampersons and, perhaps it can be used to change singing quotes?

With some Also, xml to close the tag.

Edit: Just realized how old it is, probably the information above will be suitable for future explorers.


Comments