ruby json library trouble

Discussion in 'Ruby' started by Lyes Amazouz, Jan 14, 2009.

  1. Lyes Amazouz

    Lyes Amazouz Guest

    [Note: parts of this message were removed to make it a legal post.]

    Hi everybody

    I'm trying to export some data in the Json format using the json_pure
    library

    I've well prepared my structure in my program and I used the generate method
    to get the Jon output. But, during the generation, an error occurs saying
    that it met a character that is not utf-8 encoded.?

    Do this mean that I'm obliged to give UTF-8 encoded strings in my objects to
    get my json output, and if it is the case, do you now good ruby utf-8
    encoding library to advise it to me?

    Thank you!
    --
    ===========
    | Lyes Amazouz
    | USTHB, Algiers
    ===========
     
    Lyes Amazouz, Jan 14, 2009
    #1
    1. Advertising

  2. I did not check, but probably you need to use utf8 strings, at least
    for ruby 1.8

    For encoding into utf8, you need to know what is your string's current
    encoding, and then change the string into utf8 encoding. You can use
    iconv() (google ruby iconv) for that change.

    izidor

    On 15.1.2009, at 0:48, Lyes Amazouz wrote:

    > Hi everybody
    >
    > I'm trying to export some data in the Json format using the json_pure
    > library
    >
    > I've well prepared my structure in my program and I used the
    > generate method
    > to get the Jon output. But, during the generation, an error occurs
    > saying
    > that it met a character that is not utf-8 encoded.?
    >
    > Do this mean that I'm obliged to give UTF-8 encoded strings in my
    > objects to
    > get my json output, and if it is the case, do you now good ruby utf-8
    > encoding library to advise it to me?
    >
    > Thank you!
    > --
    > ===========
    > | Lyes Amazouz
    > | USTHB, Algiers
    > ===========
     
    Izidor Jerebic, Jan 16, 2009
    #2
    1. Advertising

  3. Amazouz Loui wrote:
    > I've well prepared my structure in my program and I used the generate
    > method
    > to get the Jon output. But, during the generation, an error occurs
    > saying
    > that it met a character that is not utf-8 encoded.?


    Json *only* supports Unicode text. See http://www.unicode.org/

    If you want to send arbitrary binary data, you need to encode it first
    into a textual form, e.g. using base64 encoding.

    If you want to sent 8-bit text which is not UTF-8, then you can
    transcode it to UTF-8 (probably the "right thing" in this context), or
    base64 encode it.
    --
    Posted via http://www.ruby-forum.com/.
     
    Brian Candler, Jan 16, 2009
    #3
  4. Brian Candler, Jan 16, 2009
    #4
  5. Lyes Amazouz

    Lyes Amazouz Guest

    [Note: parts of this message were removed to make it a legal post.]

    OK, thank you Brian and Izidor,

    I will see in that way. But I want to know something more, what is exactly
    the role of the KCode Variable?

    Than kyou!



    --
    ===========
    | Lyes Amazouz
    | USTHB, Algiers
    ===========
     
    Lyes Amazouz, Jan 18, 2009
    #5
  6. Lyes Amazouz

    James Gray Guest

    On Jan 18, 2009, at 1:03 AM, Lyes Amazouz wrote:

    > I will see in that way. But I want to know something more, what is
    > exactly the role of the KCode Variable?


    I answer that specific question in this blog post:

    http://blog.grayproductions.net/articles/the_kcode_variable_and_jcode_library

    If you want more general character encoding information, you may wish
    to start reading from the beginning of that series:

    http://blog.grayproductions.net/articles/understanding_m17n

    Hope that helps.

    James Edward Gray II
     
    James Gray, Jan 18, 2009
    #6
  7. Lyes Amazouz

    Lyes Amazouz Guest

    [Note: parts of this message were removed to make it a legal post.]

    Hello James!

    Thank you for the quick answer, I will see whate you gave me


    >
    > http://blog.grayproductions.net/articles/the_kcode_variable_and_jcode_library
    >
    > If you want more general character encoding information, you may wish to
    > start reading from the beginning of that series:
    >
    > http://blog.grayproductions.net/articles/understanding_m17n
    >
    > Hope that helps.
    >
    > James Edward Gray II
    >
    >
    > Cheers!



    --
    ===========
    | Lyes Amazouz
    | USTHB, Algiers
    ===========
     
    Lyes Amazouz, Jan 20, 2009
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Florian Frank
    Replies:
    0
    Views:
    244
    Florian Frank
    Jun 30, 2009
  2. sajuptpm
    Replies:
    2
    Views:
    347
    sajuptpm
    Dec 28, 2012
  3. Acácio Centeno
    Replies:
    1
    Views:
    260
    dieter
    Feb 15, 2013
  4. Bryan Britten
    Replies:
    9
    Views:
    265
    Bryan Britten
    May 28, 2013
  5. David Karr
    Replies:
    1
    Views:
    170
    David Karr
    Jun 17, 2013
Loading...

Share This Page