[Greasemonkey] Special characters

Jeremy Dunck jdunck at gmail.com
Wed Mar 29 15:34:44 EST 2006


On 3/29/06, Vectorspace <vectorspace at ntlworld.com> wrote:
> Is there some kind of reference of special characters that would need to
> be encoded in a string, and how to encode them?
>
> Like, if I wanted to set the value of a string to http://www.google.com,
> I would need to replace // with \u002F\u002F otherwise the // would be
> interpreted as the beginning of a comment

a = "//" works just fine.

The only thing you need to escape when creating string literals is "\"
itself, since that's used to make special meanings.

a = "a\"b" yields a 3 character string, which is the sequence of
characters a, ", b.
b = "a"b" yields a syntax error.
c = "a\\b" yields a 3 character string, which is the sequence of
characters a, \, b.


More information about the Greasemonkey mailing list