HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Previous chapters we have learned how to use Ruby output "Hello, World!", English no problem, but if you output Chinese characters "Hello, World" is likely to encounter Chinese coding problem.
Ruby files if the encoding is not specified in the implementation process will be given:
#!/usr/bin/ruby -w puts "你好,世界!";
The above program execution output is:
invalid multibyte char (US-ASCII)
The above error message shows the Ruby use with ASCII encoding to read the source, the Chinese will be garbled, the solution is just the beginning of the file on# - * - coding: UTF- 8 - * - (EMAC written) or # coding = utf-8on the line.
The output is:
你好,世界!
So if we re-learning process, the source code file, then with the Chinese encoding, you need to pay attention to two things: