如何使用 \n\r\t 进行 NSLog
在我的应用程序中,我正在将 HTML 页面读取为字符串。 HTML 页面包含许多标签、换行符和新行。许多其他角色。
<style type="text/css">
h3{
font-weight:bold;
line-height:18px;
font-family:Arial;
font-size:12px;
text-align:justify;
color:black;
background-color:transparent;
width:280px;
margin:0;
}
body{
font-weight:normal;
line-height:18px;
font-family:Arial;
font-size:12px;
text-align:justify;
color:black;
background-color:transparent;
width:280px;
}
</style>
我想像下面这样替换这个字符串。 当我们在 HTML 页面上 NSLog 时,它会打印如上所示。但我想要 NSLog 如下,
\t\t<style type="text/css">\n\t\t\th3{\n
font-weight:bold;
line-height:18px;
font-family:Arial;
font-size:12px;
text-align:justify;
color:black;
background-color:transparent;
width:280px;
margin:0;
}
body{
font-weight:normal;
line-height:18px;
font-family:Arial;
font-size:12px;
text-align:justify;
color:black;
background-color:transparent;
width:280px;
}
</style>
我的意思是包括反斜杠字符。是否可以?这背后的原因 - 我想动态替换上面的样式 - 但为了替换上面的样式,我必须有源来替换 - 如何获取包含 \n&\r 字符的源?
In my application I am reading an HTML page to a string. HTML Page contains many tags, new lines & many other characters.
<style type="text/css">
h3{
font-weight:bold;
line-height:18px;
font-family:Arial;
font-size:12px;
text-align:justify;
color:black;
background-color:transparent;
width:280px;
margin:0;
}
body{
font-weight:normal;
line-height:18px;
font-family:Arial;
font-size:12px;
text-align:justify;
color:black;
background-color:transparent;
width:280px;
}
</style>
I want to replace this string like following.
When we NSLog above HTML page, it will print as above looks. But What I want to NSLog is as follows
\t\t<style type="text/css">\n\t\t\th3{\n
font-weight:bold;
line-height:18px;
font-family:Arial;
font-size:12px;
text-align:justify;
color:black;
background-color:transparent;
width:280px;
margin:0;
}
body{
font-weight:normal;
line-height:18px;
font-family:Arial;
font-size:12px;
text-align:justify;
color:black;
background-color:transparent;
width:280px;
}
</style>
I mean including backslash characters. Is it possible? The reason behind this - I want to replace above style dynamically - but for replacing above I must have source to replace - How to get source including \n&\r characters ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看 NSString 引用。你需要类似的东西:
Look at the NSString reference. You'll need something like: