包括)”在原始字符串文字中而不终止所述文字

问题描述:

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

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

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)