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

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

.

On May 20, 2011, at 11:30 AM, Ilias L. wrote:

Requirements:


http://lazaridis.com

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

On 20 Μάϊος, 23:18, Jason R. [email protected] wrote:

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

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.

.

On May 20, 11:26am, Ilias L. [email protected] wrote:

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

On 21 , 19:10, Luis L. [email protected] wrote:
[…] - 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”

.

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

[email protected]:~$ 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”

On 21 Μάϊος, 22:02, Roger B. [email protected] wrote:

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).

[email protected]:~$ 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!

.

On 20 Μάϊος, 18:26, Ilias L. [email protected] wrote:

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

fixed for ruby 1.9.3:

(changed default YAML from “syck” to “psych”, which saves utf-8 data
human readable)

http://redmine.ruby-lang.org/issues/4758

.

On 3 Ιούν, 07:26, Panagiotis A. [email protected] wrote:

Example solution:
I can successfully manage Greek (save/red) chars using “ya2yaml (0.30)”.
[…]

I can confirm this, as I’ve tried it.

But the main issue was, to enable this behaviour out-of-the-box.

As stated, it’s solved now:

http://redmine.ruby-lang.org/issues/4758

.

Hello,

On 01 Ιουν 2011, at 12:55 μ.μ., Ilias L. wrote:

fixed for ruby 1.9.3:

I can successfully manage Greek (save/red) chars using “ya2yaml (0.30)”.

Best Regards,


Panagiotis A.

email: [email protected]
blog: http://www.convalesco.org

The wise man said: “Never argue with an idiot. They bring you down to
their level and beat you with experience.”

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs