中文乱码解决办法
cmd下中文不能输入
将cmd代码页改成936:
chcp 936ruby 读取中文强制设置为utf-8
可以在文件中加一个注释语句 # encoding: UTF-8,ruby就会用utf-8格式载入
cmd输出乱码
这个解决不掉, 我看到有人用了一个第三方库来解决输出
require 'iconv' cov = Iconv.new( 'gbk', 'utf-8') puts cov.iconv("北京奥运会!")PS: Ruby程序中,最好不要出现中文,注释除外
解决ruby不支持openssl的问题
在RHEL 5.4 x86_64安装rails的时候,提示ruby不支持openssl
进入$RUBY_HOME/ext/openssl目录, 执行 ruby exconf.rb,出现如下错误:
=== OpenSSL for Ruby configurator === === Checking for system dependent stuff... === checking for t_open() in -lnsl... no checking for socket() in -lsocket... no checking for assert.h... yes === Checking for required stuff... === checking for openssl/ssl.h... no === Checking for required stuff failed. ===Makefile wasn't created. Fix the errors above.
提示没有找到ssl.h, 从http://pile with -fPIC/usr/local/ssl/lib/libssl.a: could not read symbols: Bad valuecollect2: ld returned 1 exit statusmake: *** [openssl.so] Error 1
提示重新试过编译openssl时带上-fPIC参数 。于是重新编译openssl
.confile -fPIC