Skip to content

M_Cyjb_CharUtil_NeedUnicodeEscape

CYJB edited this page Mar 20, 2024 · 2 revisions

CharUtil.NeedUnicodeEscape 方法

返回当前字符的 Unicode 字符是否需要被转义。

Namespace: Cyjb
Assembly: Cyjb (in Cyjb.dll) Version: 1.0.23+7750dd8e971297c5fa962a3bee37fb78f72793f6

语法

C#

public static bool NeedUnicodeEscape(
	this char ch,
	bool escapeVisibleUnicode = true
)

参数

 

ch
Type: System.Char
要检查是否需要转义的字符。
escapeVisibleUnicode (Optional)
Type: System.Boolean
是否转义可见的 Unicode 字符,默认为 true

返回值

Type: Boolean
如果字符需要被转义,则返回 true;不需要被转义则返回 false

备注

在 Visual Basic 和 C# 中,这个方法可以当成为类型Char的实例方法来调用。在采用实例方法语法调用这个方法时,请省略第一个参数。请参考 扩展方法 (Visual Basic)扩展方法 (C# 编程指南) 获取更多信息。

Remarks

对于 ASCII 可见字符(从 0x20 空格到 0x7E ~ 符号),会返回原始字符。

对于某些特殊字符(\0, , \a, \b, \f, \n, \r, \t, \v)以及自定义的字符,会返回其转义形式。

对于其它字符,会返回其十六进制转义形式(\u0000)。

参见

Reference

CharUtil 类
Cyjb 命名空间

Clone this wiki locally