Chin
Chin

Reputation: 20675

Ruby display unicode character

I'm trying to print out some Unicode characters:

# encoding: utf-8
puts "ử ậ ắ ặ ố ồ"

If I run it through Powershell, this is what I get:

enter image description here

If I run it through cmd, this is what I get:

enter image description here

If I run it in Eclipse (with Aptana Studio 3 plugin), this is what I get:

enter image description here

Is it a problem with my system/software or is it Ruby's problem? How can I get it to work?

It works on Ideone though: http://ideone.com/PdycKH

Upvotes: 2

Views: 478

Answers (2)

Chin
Chin

Reputation: 20675

I figured it out:

  • For cmd and Powershell, I have to change the font (I changed to Consolas)
  • In Eclipse, I have to change the encoding: go to Run/Run configurations, select the Common tab, change the Encoding to Other: UTF-8

Upvotes: 1

jefflunt
jefflunt

Reputation: 33954

Ruby supports it no problem, and setting the formatting at the top of the file is the way to go.

The issue is the display via the command line window. You need to use both a font and character page that supports Unicode display.

See this question regarding doing this in the Windows command line.

About the chcp command

Upvotes: 4

Related Questions