Loading ...
Sorry, an error occurred while loading the content.

JavaScript and Unicode

Expand Messages
  • Douglas Crockford
    There are several Unicode characters that JavaScript mishandles, either by silent deletion, or by treating them as line ending characters. json2.js now escapes
    Message 1 of 4 , May 3, 2008
    View Source
    • 0 Attachment
      There are several Unicode characters that JavaScript mishandles,
      either by silent deletion, or by treating them as line ending characters.

      json2.js now escapes those characters when it parses and when it
      minifies, so they can now be used correctly in JSON applications.

      http://www.JSON.org/json.js
    • Stephen M. McKamey
      It appears that versions of http://json.org/json2.js starting around May 2008 have issues in Opera. I ve verified this in Opera 9.52 and Opera 9.27. The issue
      Message 2 of 4 , Dec 15, 2008
      View Source
      • 0 Attachment
        It appears that versions of http://json.org/json2.js starting around
        May 2008 have issues in Opera. I've verified this in Opera 9.52 and
        Opera 9.27.

        The issue appears in the RegExp on line 190 of the 2008-11-19 version.
        My guess is that Opera does not like escaped unicode in literal
        RegExp? It throws a syntax error which causes the rest of the script
        to not load.

        Does anyone know of a fix or work-around for this?

        Thanks in advance,
        smm

        --- on Sat May 3, 2008 7:42 am, "Douglas Crockford" <douglas@...>
        wrote:
        >
        > There are several Unicode characters that JavaScript mishandles,
        > either by silent deletion, or by treating them as line ending
        characters.
        >
        > json2.js now escapes those characters when it parses and when it
        > minifies, so they can now be used correctly in JSON applications.
        >
        > http://www.JSON.org/json.js
      • Leen Besselink
        ... Hi, My college and me at work noticed this as well, we made a patch for it at the time. It seems we forgot to report it. It s fixed in newer versions of
        Message 3 of 4 , Dec 16, 2008
        View Source
        • 0 Attachment
          On Tue, Dec 16, 2008 at 01:43:48AM -0000, Stephen M. McKamey wrote:
          > It appears that versions of http://json.org/json2.js starting around
          > May 2008 have issues in Opera. I've verified this in Opera 9.52 and
          > Opera 9.27.
          >
          > The issue appears in the RegExp on line 190 of the 2008-11-19 version.
          > My guess is that Opera does not like escaped unicode in literal
          > RegExp? It throws a syntax error which causes the rest of the script
          > to not load.
          >
          > Does anyone know of a fix or work-around for this?
          >

          Hi,

          My college and me at work noticed this as well, we made a patch for
          it at the time. It seems we forgot to report it. It's fixed in newer
          versions of Opera.

          --- json.js 2008/05/28 10:12:29 1.3
          +++ json.js 2008/06/13 07:04:16 1.4
          @@ -177,8 +177,8 @@
          f(this.getUTCSeconds()) + 'Z';
          };

          - var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
          - escapeable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
          + var cx = new RegExp("[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]", "g"),
          + escapeable = new RegExp("[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]","g"),
          gap,
          indent,
          meta = { // table of character substitutions

          > Thanks in advance,
          > smm
          >
          > --- on Sat May 3, 2008 7:42 am, "Douglas Crockford" <douglas@...>
          > wrote:
          > >
          > > There are several Unicode characters that JavaScript mishandles,
          > > either by silent deletion, or by treating them as line ending
          > characters.
          > >
          > > json2.js now escapes those characters when it parses and when it
          > > minifies, so they can now be used correctly in JSON applications.
          > >
          > > http://www.JSON.org/json.js
          >
          _____________________________________
          New things are always on the horizon.
        • Stephen M. McKamey
          Ahh, thanks! I tried that but thought it didn t work because this whole thing was masking a different Opera issue. Your post made me go back and look more
          Message 4 of 4 , Dec 16, 2008
          View Source
          • 0 Attachment
            Ahh, thanks! I tried that but thought it didn't work because this
            whole thing was masking a different Opera issue. Your post made me go
            back and look more closely. Seems to do the trick.

            Douglas, can you update json2.js to use the RegExp constructor syntax
            instead of RegExp literals?

            Thanks,
            smm

            --- In json@yahoogroups.com, Leen Besselink <leen@...> wrote:
            >
            > On Tue, Dec 16, 2008 at 01:43:48AM -0000, Stephen M. McKamey wrote:
            > > It appears that versions of http://json.org/json2.js starting
            around
            > > May 2008 have issues in Opera. I've verified this in Opera 9.52
            and
            > > Opera 9.27.
            > >
            > > The issue appears in the RegExp on line 190 of the 2008-11-19
            version.
            > > My guess is that Opera does not like escaped unicode in literal
            > > RegExp? It throws a syntax error which causes the rest of the
            script
            > > to not load.
            > >
            > > Does anyone know of a fix or work-around for this?
            > >
            >
            > Hi,
            >
            > My college and me at work noticed this as well, we made a patch for
            > it at the time. It seems we forgot to report it. It's fixed in newer
            > versions of Opera.
            >
            > --- json.js 2008/05/28 10:12:29 1.3
            > +++ json.js 2008/06/13 07:04:16 1.4
            > @@ -177,8 +177,8 @@
            > f(this.getUTCSeconds()) + 'Z';
            > };
            >
            > - var cx = /[\u0000\u00ad\u0600-
            \u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-
            \u206f\ufeff\ufff0-\uffff]/g,
            > - escapeable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-
            \u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-
            \u206f\ufeff\ufff0-\uffff]/g,
            > + var cx = new RegExp("[\u0000\u00ad\u0600-
            \u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-
            \u206f\ufeff\ufff0-\uffff]", "g"),
            > + escapeable = new RegExp("[\\\"\x00-\x1f\x7f-
            \x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-
            \u202f\u2060-\u206f\ufeff\ufff0-\uffff]","g"),
            > gap,
            > indent,
            > meta = { // table of character substitutions
            >
            > > Thanks in advance,
            > > smm
            > >
            > > --- on Sat May 3, 2008 7:42 am, "Douglas Crockford" <douglas@>
            > > wrote:
            > > >
            > > > There are several Unicode characters that JavaScript mishandles,
            > > > either by silent deletion, or by treating them as line ending
            > > characters.
            > > >
            > > > json2.js now escapes those characters when it parses and when it
            > > > minifies, so they can now be used correctly in JSON
            applications.
            > > >
            > > > http://www.JSON.org/json.js
            > >
            > _____________________________________
            > New things are always on the horizon.
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.