濮阳杆衣贸易有限公司

主頁 > 知識(shí)庫 > Ruby在cmd下中文顯示亂碼以及不支持OpenSSL的問題解決

Ruby在cmd下中文顯示亂碼以及不支持OpenSSL的問題解決

熱門標(biāo)簽:湖州u友防封電銷卡 百度地圖標(biāo)注自定義圖片 常德電銷平臺(tái)外呼系統(tǒng)軟件價(jià)格 滴滴外呼系統(tǒng) 徐州網(wǎng)絡(luò)外呼系統(tǒng)哪個(gè)好 電銷機(jī)器人廠商代理 地圖標(biāo)注賺錢項(xiàng)目注冊(cè) 高德地圖標(biāo)注客服 白銀外呼paas系統(tǒng)

中文亂碼解決辦法
cmd下中文不能輸入

將cmd代碼頁改成936:

chcp 936

ruby 讀取中文強(qiáng)制設(shè)置為utf-8

可以在文件中加一個(gè)注釋語句 # encoding: UTF-8,ruby就會(huì)用utf-8格式載入

cmd輸出亂碼

這個(gè)解決不掉, 我看到有人用了一個(gè)第三方庫來解決輸出 

require 'iconv' 
cov = Iconv.new( 'gbk', 'utf-8')   
puts cov.iconv("北京奧運(yùn)會(huì)!")

PS: Ruby程序中,最好不要出現(xiàn)中文,注釋除外

解決ruby不支持openssl的問題
在RHEL 5.4 x86_64安裝rails的時(shí)候,提示ruby不支持openssl

進(jìn)入$RUBY_HOME/ext/openssl目錄, 執(zhí)行 ruby exconf.rb,出現(xiàn)如下錯(cuò)誤:

=== 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://www.openssl.org/ 下載了openssl-0.9.8k.tar.gz。 解壓,執(zhí)行configure make make install. 回到$RUBY_HOME/ext/openssl重新執(zhí)行

ruby extconf.rb --with-openssl-include=/usr/local/ssl/include/ --with-openssl-lib=/usr/local/ssl/lib

成功。但接下來執(zhí)行make時(shí) 又出現(xiàn)新的錯(cuò)誤:

~/sources/ruby-1.8.7-p174/ext/openssl$ sudo make

gcc -shared -o openssl.so ossl_x509.o ossl_x509cert.o ossl_x509crl.o ossl_pkcs7.o ossl_cipher.o ossl_pkey_dh.o ossl_ssl_session.o ossl_x509attr.o ossl_x509ext.o ossl_ocsp.o ossl_asn1.o ossl_x509name.o ossl_x509revoked.o ossl_rand.o ossl_pkcs12.o ossl_x509store.o ossl_ssl.o ossl.o ossl_digest.o ossl_config.o ossl_pkcs5.o ossl_bio.o ossl_pkey_dsa.o ossl_pkey.o ossl_x509req.o ossl_pkey_ec.o ossl_hmac.o openssl_missing.o ossl_ns_spki.o ossl_pkey_rsa.o ossl_engine.o ossl_bn.o -L. -L/usr/local/ruby/lib -Wl,-R/usr/local/ruby/lib -L/usr/local/ssl/lib -Wl,-R/usr/local/ssl/lib -L. -rdynamic -Wl,-export-dynamic  -lssl -lcrypto -lrt -ldl -lcrypt -lm  -lc

/usr/bin/ld: /usr/local/ssl/lib/libssl.a(s2_meth.o): relocation R_X86_64_32 against `a local symbol'

 can not be used when making a shared object; recompile with -fPIC

/usr/local/ssl/lib/libssl.a: could not read symbols: Bad value

collect2: ld returned 1 exit status

make: *** [openssl.so] Error 1


提示重新試過編譯openssl時(shí)帶上-fPIC參數(shù) 。于是重新編譯openssl

.confile -fPIC

您可能感興趣的文章:
  • 詳解Ruby語言中的注釋用法與中文編碼問題

標(biāo)簽:永州 遼寧 張家界 荊門 公主嶺 梧州 三沙 普洱

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Ruby在cmd下中文顯示亂碼以及不支持OpenSSL的問題解決》,本文關(guān)鍵詞  Ruby,在,cmd,下,中文,顯示,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Ruby在cmd下中文顯示亂碼以及不支持OpenSSL的問題解決》相關(guān)的同類信息!
  • 本頁收集關(guān)于Ruby在cmd下中文顯示亂碼以及不支持OpenSSL的問題解決的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    吉林省| 手游| 马龙县| 山东省| 三都| 久治县| 山阳县| 师宗县| 无棣县| 南涧| 海南省| 滨州市| 元氏县| 荃湾区| 乌兰察布市| 杂多县| 襄樊市| 云和县| 育儿| 丽水市| 泰宁县| 万山特区| 连山| 磐石市| 武冈市| 阳泉市| 东辽县| 江津市| 湖北省| 丘北县| 黄山市| 延津县| 佛冈县| 电白县| 余姚市| 宁国市| 墨竹工卡县| 双柏县| 南通市| 牟定县| 洛川县|