ES3.1 Draft: String generics
Erik Arvidsson
erik.arvidsson at gmail.com
Wed May 7 10:39:35 PDT 2008
Mike,
We are saying the same thing. Maybe it is my escaping that is
confusing you. Mine also has the length 6. My example is using a JS
string literal where yours does not.
On Wed, May 7, 2008 at 10:12, Mike Shaver <mike.shaver at gmail.com> wrote:
> On Wed, May 7, 2008 at 12:17 PM, Erik Arvidsson
> <erik.arvidsson at gmail.com> wrote:
> > The quote method needs more specification. It needs to escape a lot
> > more characters than just single and double quotes. The basic rule is
> > that String.prototype.quote should return a string that would be a
> > valid string literal for that string.
> >
> > For example:
> >
> > "a\nb".quote() => "\"a\\nb\""
>
> I would expect that
>
> "a\nb".quote()
>
> would produce
>
> "a\nb" (a string with 6 characters)
>
> and that's what Firefox implements, along with a toplevel uneval that
> works on strings, arrays, objects, etc.. I think it would be very
> confusing for us to convert single newline characters to an escaped
> backslash and 'n'!
>
> Having a way to escape metacharacters could be valuable, but I think
> much more valuable for the set of metacharacters that are meaningful
> to regular expressions. I think that's provided by more toolkits than
> .quoteQuotes, and is harder to get right.
>
> Mike
>
--
erik
More information about the Es4-discuss
mailing list