encoder class : JavaScriptStringEncode(string,bool) method

Description

Encodes a string.

Syntax

encoderInstance.JavaScriptStringEncode(string targetString, bool addDoubleQuotes)

Arguments

ClassNameDescription
stringtargetStringA string to encode.
booladdDoubleQuotesA value that indicates whether double quotation marks will be included around the encoded string.

Return value

ClassDescription
stringAn encoded string.

Sample code

1:

encoder e = new encoder();

2:

string str = "This is '.";

3:

string encoded = e.JavaScriptStringEncode(str, true); // "This is \u0027."

Notes

It's a wrapper of the System.Web.HttpUtility.JavaScriptStringEncode(String,Bool) method.

Links for reference

Copyright © Cooker All rights reserved.