字符串文字而不必转义特殊字符?

编程入门 行业动态 更新时间:2024-10-26 14:33:18
本文介绍了字符串文字而不必转义特殊字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在Objective-c中是否有字符串文字形式,不需要转义特殊字符?换句话说,我正在寻找一个相当于Python的三重报价。

Is there a string literal form in Objective-c that does not require escaping special characters? In other words, I'm looking for an equivalent to the Python triple quote.

我试图把一些HTML放入一个 NSString ,并且希望避免从所有HTML属性中转义引号。

I'm trying to put some HTML into an NSString, and would like to avoid having to escape the quotes from all the HTML attributes.

推荐答案

没有相当于三重报价;字符串文字必须始终使用特殊字符的转义。

There's no equivalent to the triple-quote; string literals must always use escapes for special characters.

也许最好的做法是将HTML放入与源文件分开的文件中,然后使用rel =nofollow> - [NSString initWithContentsOfFile:encoding:error:] (或相关的 initWithContentsOfURL:... )。

Perhaps the best thing to do would be to put your HTML into a file separate from your source, then create the string using -[NSString initWithContentsOfFile:encoding:error:] (or the related initWithContentsOfURL:...).

更多推荐

字符串文字而不必转义特殊字符?

本文发布于:2023-10-13 17:13:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1488589.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   而不必   特殊字符   文字

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!