Ruby散列中保存中文,使用puts输出时只能显示unicode码,请问如何显示中文?
黄舟
黄舟 2017-04-24 09:14:09
0
3
681

Ruby散列中保存中文,使用puts输出时只能显示unicode码,请问如何显示中文?

源码:

hash={a:"第一条",b:"第二条",c:"第三条"}
puts hash

输出结果:

{:a=>"\u7B2C\u4E00\u6761", :b=>"\u7B2C\u4E8C\u6761", :c=>"\u7B2C\u4E09\u6761"}
黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(3)
刘奇

Open irb input

Encoding.locale_charmap

Check if your encoding is => "UTF-8"

The Ruby version must be greater than 1.8

Check whether you have readline installed

大家讲道理

Warning: Trying to solve a non-existent problem.

刘奇

I tested it on CentOS and Mac and didn’t find the problem you mentioned.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template