URL编码和HTML编码NSStrings [英] URL-encoding and HTML-encoding NSStrings
问题描述
[NSString stringWithContentsOfFile:<#(NSString *)path#>编码:其中#(NSStringEncoding)ENC#>错误:<#(NSError **)错误#>]
工作我的预期我以为会转换特殊字符,如<到等效的HTML实体,即<在这种情况下
以下是对与此主题相关的w3school链接(一般)的引用:
< a href =http://www.w3schools.com/tags/ref_urlencode.asp =nofollow noreferrer> HTML URL编码参考
感谢预期。
使用给定的编码返回接收者的表示,以确定转换接收器所需的百分比转义一个合法的URL字符串。
- (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding
和
返回一个新的字符串,通过在接收方中替换所有百分号转义,匹配的字符由给定的编码确定。
- (NSString *)stringByReplacingPercentEscapes usingEncoding:(NSStringEncoding)encoding
Is their a method to encode/decode HTML and URL (in Xcode, using Objective-C)?
[NSString stringWithContentsOfFile:<#(NSString *)path#> encoding:<#(NSStringEncoding)enc#> error:<#(NSError **)error#>]
This doesn't seem to work how i expected. I thought it will convert special characters like "<" to equivalent HTML entities i.e. "<" in this case.
Here's a reference to the w3school link related to this topic (general):
Thanking in anticipation.
Returns a representation of the receiver using a given encoding to determine the percent escapes necessary to convert the receiver into a legal URL string.
- (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding
and
Returns a new string made by replacing in the receiver all percent escapes with the matching characters as determined by a given encoding.
- (NSString *)stringByReplacingPercentEscapesUsingEncoding:(NSStringEncoding)encoding
这篇关于URL编码和HTML编码NSStrings的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!