Results 1 to 2 of 2

Thread: Ext.encode and UTF-8 characters

  1. #1
    Sencha User
    Join Date
    Sep 2012
    Location
    Germany
    Posts
    8
    Vote Rating
    0
      0  

    Default Ext.encode and UTF-8 characters

    Hi there,
    as already mentioned in the comments of the function Ext.encode (http://docs.sencha.com/ext-js/4-1/#!...-method-encode) there is an unexpected behavior of this function (at least for me).
    When i have some sepcial characters like "german umlauts" "".
    Ext.encode does escape the characters as seen in the following example:

    Code:
    Ext.encode("Buerle")
    results in:
    "B\u00e4uerle"
    Of course i tried to enable Ext.USE_NATIVE_JSON to use the native JSON encode methode from the browser if possible but this does result in the same outputs.

    Code:
    var string = "Buerle";        
    console.log(string);
    Ext.USE_NATIVE_JSON = true;
    string = Ext.encode(string);
    Ext.USE_NATIVE_JSON = false;
    console.log(string);
    gives me this output:

    Buerle
    "B\u00e4uerle"
    I am working with Chrome v24 and Firefox v16.

    May someone give me a hint how to solve this?
    Thanks in advance!

  2. #2
    Sencha Premium Member
    Join Date
    Nov 2012
    Location
    GER
    Posts
    10
    Answers
    1
    Vote Rating
    0
      0  

    Default

    i don't know what you are expecting, but this is the itended behavior

    when using UTF-8 you have to keep in mind, that the first 128 character (same as ASCII) are made up of 1 Byte. when you the first bit is set to 1 (values >=128) a second byte is used to represent the character

    since Umlaute are not specified in ASCII they typically consist of 2 Bytes and are converted to their hex representation for data interchange

    see JSON-specification at json.org
    HTML Code:
    char
    any-Unicode-character-
        except-"-or-\-or-
        control-character\"
     \\
     \/
     \b
     \f
     \n
     \r
     \t
     \u four-hex-digits

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •