HttpUtility.JavaScriptStringEncode 方法

定义

对字符串进行编码。

重载

JavaScriptStringEncode(String)

对字符串进行编码。

JavaScriptStringEncode(String, Boolean)

对字符串进行编码。

注解

此方法对字符串进行编码。 例如,单引号和双引号作为 \'\" 包含在编码的字符串中。

JavaScriptStringEncode(String)

Source:
HttpUtility.cs
Source:
HttpUtility.cs
Source:
HttpUtility.cs

对字符串进行编码。

public static string JavaScriptStringEncode(string? value);
public static string JavaScriptStringEncode(string value);

参数

value
String

要编码的字符串。

返回

已编码的字符串。

适用于

.NET 10 和其他版本
产品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

JavaScriptStringEncode(String, Boolean)

Source:
HttpUtility.cs
Source:
HttpUtility.cs
Source:
HttpUtility.cs

对字符串进行编码。

public static string JavaScriptStringEncode(string? value, bool addDoubleQuotes);
public static string JavaScriptStringEncode(string value, bool addDoubleQuotes);

参数

value
String

要编码的字符串。

addDoubleQuotes
Boolean

一个指示双引号是否将包含在已编码字符串周围的值。

返回

已编码的字符串。

适用于

.NET 10 和其他版本
产品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1