BARRIER - ruby yaml - utf-8 characters not human readable

I

Ilias Lazaridis

After reading within some archives, it seems that the standard-
behaviour of ruby is to save utf-8 data within yaml files in this
form:

äïêéìÞ => "\x9B\xA6\xA1\xA0\xA3\xE3"

Is this so?

If yes, what is the simplest way to change this behaviour?

Requirements:

* solution should be usable for end-users
* solution should not require any changes within the application
which uses yaml

Example solution:

* gem install another-yaml-which-saves-human-readable-utf-8

..
 
J

Jason Roelofs

After reading within some archives, it seems that the standard-
behaviour of ruby is to save utf-8 data within yaml files in this
form:
=20
=CE=B4=CE=BF=CE=BA=CE=B9=CE=BC=CE=AE =3D> "\x9B\xA6\xA1\xA0\xA3\xE3"
=20
Is this so?
=20
If yes, what is the simplest way to change this behaviour?
=20
Requirements:
=20
* solution should be usable for end-users
* solution should not require any changes within the application
which uses yaml
=20
Example solution:
=20
* gem install another-yaml-which-saves-human-readable-utf-8
=20
.
=20

Here's an idea:

"Fix" it yourself. I'd also ask you to quit with the subject FUD but we =
all know you don't know how to read other people's replies.

- Jason=
 
I

Ilias Lazaridis

Here's an idea:

"Fix" it yourself. I'd also ask you to quit with the subject FUD but we all know you don't know how to read other people's replies.

Mr. Roelofs.

I've observed the utf-8 behaviour of ruby yaml on a local installation
(ruby 1.9.2 windows 7 greek). As a first step I've read some existent
topics (which confirmed my observations).

The usual step (before going to a dev-list or to an issue-tracking-
system) is to *confirm* the issue within a user medium.

It is a standard process that I'm following, in order to protect the
time of the core developers.

I ask you friendly to respect the public nature of this usenet group -
please refrain from further off-topic comments.

..
 
L

Luis Lavena

After reading within some archives, it seems that the standard-
behaviour of ruby is to save utf-8 data within yaml files in this
form:

äïêéìÞ => "\x9B\xA6\xA1\xA0\xA3\xE3"

Is this so?

Serialization of data depends on encoding. Learn about encodings and
Ruby support of it before asking questions.

Learn YAML specification about how it serializes non-ASCII
information.

If YAML doesn't fit you, write your own.

YAML specs:
http://www.yaml.org/spec/

Ruby encoding analysis:
http://blog.grayproductions.net/articles/ruby_19s_three_default_encodings
http://blog.segment7.net/2011/02/02/string-encoding-quick-start
http://blog.segment7.net/2010/12/17/from-iconv-iconv-to-string-encode
 
I

Ilias Lazaridis

[...] - off context comments

Can someone please confirm, if this is the standard ruby 1.9
behaviour?

utf-8 data saved to yaml file:

äïêéìÞ becomes "\x9B\xA6\xA1\xA0\xA3\xE3"

..
 
R

Roger Braun

I know that Illias is probably trolling, but there is a way to get the
desired behaviour: Use Psych (https://github.com/tenderlove/psych).

roger@roger-MS-7621:~$ irb
ruby-1.9.2-p180 :001 > require "psych"
=3D> true
ruby-1.9.2-p180 :003 > require "yaml"
=3D> true
ruby-1.9.2-p180 :004 > YAML.dump("=C3=B6=C3=B6=C3=B6")
=3D> "--- =C3=B6=C3=B6=C3=B6\n...\n"


--=20
Roger Braun
rbraun.net | humoralpathologie.de
 
I

Ilias Lazaridis

I know that Illias is probably trolling,

Mr. Braun, I've placed a simple technical question. If someone is
"trolling", than it's not me, but those who write off-topic, off-
context and those who talk about trolling. This starts to become
annoying, mostly because it gives this medium an unprofessional touch,
which reflects negatively on ruby.

This should be avoided.
but there is a way to get the
desired behaviour: Use Psych (https://github.com/tenderlove/psych).

roger@roger-MS-7621:~$ irb
ruby-1.9.2-p180 :001 > require "psych"
 => true
ruby-1.9.2-p180 :003 > require "yaml"
 => true
ruby-1.9.2-p180 :004 > YAML.dump("ööö")
 => "--- ööö\n...\n"

I've verified this solution, it works fine (utf-8 arrives human-
readable within the yaml file, as it should).

require "psych" // place before yaml
require "yaml"

alternative:

require "yaml"
YAML::ENGINE.yamler = "psych"

-

Thanks a lot!

..
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top