URL-encoding and HTML-encoding NSStrings

后端 未结 4 1828
滥情空心
滥情空心 2021-01-04 22:14

Is their a method to encode/decode HTML and URL (in Xcode, using Objective-C)?

[NSString stringWithContentsOfFile:<#(NSString *)path#> encoding:<#(         


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-04 22:48

    Use CFStringTransform for HTML entity encoding/decoding:

    CFStringTransform((CFTypeRef)yourMutableString, NULL, CFSTR("Any-Hex/XML"), FALSE );

    You need to use the ICU transform "Any-Hex/XML". kCFStringTransformToXMLHex isn't aggressive enough.

提交回复
热议问题