2

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

Chin
  • 19,717
  • 37
  • 107
  • 164

2 Answers2

4

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

Community
  • 1
  • 1
jefflunt
  • 33,527
  • 7
  • 88
  • 126
1

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
Chin
  • 19,717
  • 37
  • 107
  • 164