首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > Ruby Rails >

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

2012-12-21 
用Ruby查找替换UTF-8文件中的中文字符Precondition:1. The Source Java file is saved as UTF-8 type2. Th

用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
 

热点排行