包括)”在原始字符串文字中而不终止所述文字 [英] Include )" in raw string literal without terminating said literal

查看:91
本文介绍了包括)”在原始字符串文字中而不终止所述文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的示例中,两个字符终止了原始字符串文字。

序列可能会出现在我的文本中,即使在其中找到该序列,我也希望字符串继续。

The two characters )" terminate the raw string literal in the example below.
The sequence )" could appear in my text at some point, and I want the string to continue even if this sequence is found within it.

R"(  
    Some Text)"  
)";       // ^^

如何在字符串文字中包含序列而不终止它?

How can I include the sequence )" within the string literal without terminating it?

推荐答案

原始字符串文字让您指定一个几乎任意*分隔符:

Raw string literals let you specify an almost arbitrary* delimiter:

//choose ### as the delimiter so only )###" ends the string
R"###(  
    Some Text)"  
)###";  






*确切的规则是:基本源字符集的任何成员,除了:
空格,左括号(,右括号),反斜杠\,
和表示水平制表符,
垂直制表符的控制字符,换页和换行符(N3936§2.14.5[lex.string]语法)和最多16个字符(§2.14.5/ 2)

这篇关于包括)”在原始字符串文字中而不终止所述文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆