ruby json library trouble

L

Lyes Amazouz

[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!
 
I

Izidor Jerebic

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
 
B

Brian Candler

Amazouz said:
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.
 
L

Lyes Amazouz

[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!
 
J

James Gray

L

Lyes Amazouz

[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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top