Ruby Chinese encoding
In the past sections we have figured out how to yield "Hi, World!" in Ruby. There is no issue in English, however on the off chance that you yield the Chinese character "Hi, the world" is conceivable Will experience Chinese coding issues.
If no encoding is determined in the Ruby document, a blunder will happen amid execution:
#!/usr/canister/ruby - w Puts "Hello, the world!";
The above program execution yield is:
invalid multibyte char (US-ASCII )
The above blunder message demonstrates that Ruby uses ASCII encoding to peruse the source code. Chinese will be confused. The arrangement is to include # - *-coding: UTF-8 - *- toward the start of the document. EMAC) or #coding=utf-8 will do.
The yield is:
Hello, the world!
So in the event that you are adapting once more, on the off chance that you incorporate Chinese code in the source code record, you have to focus on two points:
- 1. You should include # - *-coding: UTF-8 - *- to the main line to advise the translator to utilize utf-8 to parse the source code.
- 2. The code of the supervisor spare document must be set to utf-8.