Converts the specified string into a valid string constant of JavaScript. In particular, this includes:
Character | Escape |
\ |
\\ |
' |
\' |
" |
\" |
0x0A |
\n |
0x0D |
\r |
0x09 |
\t |
\uxxxx
Exactly which characters are considered unprintable depends on the character encoding
of the (HTML) output format specified in the format
parameter.
str
Specify the string to encode.
format
Specify the output format, which provides the character encoding of the destination output.Returns:When this parameter is not specified, the output format associated with the current template will be used by default. That is the same as the call:
encodeJScriptString(str, output.format)
If this parameter is
null
, the ASCII encoding will be assumed. That is, all characters beyond the interval:will be converted into Unicode escapes.0x20 <= c < 0x80
The string ready to be inserted in the generated HTML output as a JavaScript constant.
See Also:
GOMContext.output,
OutputFormat.encoding