I am using nsxmlparser and wondering how to parse ISO-8859-1 in NSString correctly.
I am currently getting w / Â results for double-byte characters.
The XML I use (not created by me) starts with <?xml version="1.0" encoding="ISO-8859-1"?>
<?xml version="1.0" encoding="ISO-8859-1"?>
Here are the main calls I use (missed NSThread calls).
NSString *xmlFilePath = [[NSBundle mainBundle] pathForResource:sampleFileName ofType:@"xml"]; NSString *xmlFileContents = [NSString stringWithContentsOfFile:xmlFilePath encoding:NSUTF8StringEncoding error:nil]; NSData *data = [xmlFileContents dataUsingEncoding:NSUTF8StringEncoding]; NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data]; [parser setDelegate:self]; [parser parse];
The XML specification recommends explicit character encoding declarations in document prologs. Your input document probably has one; which will tell you the encoding that the parser should use to interpret character input.
, UTF-8 UTF-16 ( , ).
, XML , , , Doing It Wrong ™ , XML.
, , ISO-8859-1, ( ), , UTF-8. " utf-8", , UTF-8, UTF-8. , UTF-8, . UTF-8, , (, UTF-8, ).
, , XML HTTP-, HTTP.
, , XML . , feedparser (Python) XML-XML ( , ).
Source: https://habr.com/ru/post/1737865/More articles:Firefox redirect response to xhr request - javascriptTimeSpan for a localized string in C # - c #removal of HBITMAP leads to runtime access violation - c ++PHP: How do I scroll through each XML file in a directory? - xmlhttp (/ * argument here * /) How is this object (Http) used without an explicit or implicit method? - scala. Кроме того, выбрасывает исключение - vb.netHow to authenticate a Windows Mobile client calling web services in a web application - securityPython accepting float for string - pythonC ++ prints pointer value - c ++Gracefully exiting a thread in Ruby - multithreadingAll Articles