简体   繁体   English

逐字字符串文字中是否可以使用“ Unicode字符转义序列”?

[英]Is it possible to use “Unicode character escape sequences” in verbatim string literals?

I want to put escapted unicode chars in verbatim string literals, but I can't figure out how to do it? 我想将转义的Unicode字符放在逐字字符串文字中,但是我不知道该怎么做? (maybe I missing somthing simple or its not possible?) (也许我缺少简单的东西还是不可能?)

For example I want to do something like this: 例如,我想做这样的事情:

// Invalid
@"\b hello \u200f world"
// Invalid

Where \‏ is interpreted as unicode RTL mark not as string '\\\‏" \\ u200f被解释为unicode RTL标记,而不是字符串'\\\\ u200f”

I know I can do this this: 我知道我可以这样做:

"\\b hello \u200f world"

but verbatim string literals are useful when your string contain lots of '\\' chars. 但是当您的字符串包含很多'\\'字符时,逐字字符串文字非常有用。

No. To quote MSDN : 否。引用MSDN

In a verbatim string literal, the characters between the delimiters are interpreted verbatim, the only exception being a quote-escape-sequence. 在逐字字符串文字中,定界符之间的字符逐字解释,唯一的例外是引号-转义序列。 In particular, simple escape sequences and hexadecimal and Unicode escape sequences are not processed in verbatim string literals. 特别是,简单的转义序列以及十六进制和Unicode转义序列不在逐字字符串文字中处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM