Ruby is garbled in Chinese characters in cmd and does not support OpenSSL. rubyopenssl

Source: Internet
Author: User

Ruby is garbled in Chinese characters in cmd and does not support OpenSSL. rubyopenssl

Chinese garbled code Solution
You cannot enter Chinese Characters in cmd.

Change the cmd code page to 936:

chcp 936

Ruby enforces UTF-8 for reading Chinese Characters

You can add a comment statement in the file # encoding: UTF-8, ruby will be loaded in UTF-8 format

Cmd output garbled characters

This cannot be solved. I see someone uses a third-party library to solve the output.

Require 'iconv' cov = iconv. new ('gbk', 'utf-8') puts cov. Iconv ("Beijing Olympics! ")

PS: In Ruby programs, it is best not to show Chinese characters, except for comments

Solve the problem that ruby does not support openssl.
When installing rails in RHEL 5.4 x86_64, the following error occurs: ruby does not support openssl.

Go to the $ RUBY_HOME/ext/openssl directory and run ruby exconf. rb. the following error occurs:

=== 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.

The prompt is that ssl. h is not found and openssl-0.9.8k.tar.gz is downloaded from the http://www.openssl.org. Decompress the package and execute configure & make install. Return to $ RUBY_HOME/ext/openssl and re-execute.

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

Successful. However, a new error occurs when you execute make:

~/sources/ruby-1.8.7-p174/ext/openssl$ sudo makegcc -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 valuecollect2: ld returned 1 exit statusmake: *** [openssl.so] Error 1


The system prompts you to re-compile openssl with the-fPIC parameter. So we re-compiled openssl.

.confile -fPIC

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.