读书人

用Ruby查寻替换UTF-8文件中的中文字符

发布时间: 2012-12-21 12:03:49 作者: rapoo

用Ruby查找替换UTF-8文件中的中文字符
Precondition:
1. The Source Java file is saved as UTF-8 type
2. The Source java file containts some chinese words as comments for some test data.
3. My ruby code file is saved as UTF-8 as well.

Requirement:
1. Find all the '克' in the java files under a foder, and repleace it to '可'
2. User runs the replace.rb file through command line like:
replace <dir name>

Code: replace.rb

This way doesn't work.  I don't know the cause so far.

Udpaded on 26/01/2011
I found the solution:
change the source code from
 

读书人网 >Ruby Rails

热点推荐