Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list valid Iconv encodings in Ruby?

Tags:

ruby

encoding

how to get a list of valid Iconv encodings in Ruby 1.9.1 under windows 7?

like image 805
Fluffy Avatar asked Sep 23 '09 12:09

Fluffy


2 Answers

Maybe this will help:

puts Encoding.list
puts Encoding.aliases

It returns a list of loaded encodings, and a hash of encoding's aliases:

ASCII-8BIT
UTF-8
US-ASCII
Big5
CP949
Emacs-Mule
EUC-JP
EUC-KR
EUC-TW
...



   {"BINARY"=>"ASCII-8BIT", "CP437"=>"IBM437", "CP737"=>"IBM737", "CP775"=>"IBM775",
 "IBM850"=>"CP850", "CP857"=>"IBM857", "CP860"=>"IBM860", "CP861"=>"IBM861",
 "CP862"=>"IBM862", "CP863"=>"IBM863", "CP864"=>"IBM864", "CP865"=>"IBM865", ... 
like image 128
Pavel Chernov Avatar answered Oct 03 '22 08:10

Pavel Chernov


The list is not maintained by Ruby so you can't do it from Ruby. Ruby simply uses whatever iconv you've installed on the system. If you have the full iconv installation, you can get the list from iconv like,

 iconv /l

If you just have the library (iconv.dll), there is no way to get the list.

Most implementation is based on GNU iconv and the list is very static. You can just go to any Linux machine and type "iconv -l" to get the list.

like image 30
ZZ Coder Avatar answered Oct 03 '22 07:10

ZZ Coder