1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/ext/iconv/charset_alias.rb
nobu 26fcfd1bb5 * ext/iconv/iconv.c (map_charset): use lower case keys.
* ext/iconv/iconv.c (iconv_fail): just yield error and return the
  result if a block is given.

* ext/iconv/iconv.c (iconv_convert): yield error and append the
  result if a block is given.

* ext/iconv/charset_alias.rb (charset_alias): optional third
  argument.

* ext/iconv/charset_alias.rb (charset_alias): use CP932 instead of
  SHIFT_JIS on cygwin.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-09-01 15:41:31 +00:00

39 lines
1 KiB
Ruby

#! /usr/bin/ruby
require 'rbconfig'
# http://www.ctan.org/tex-archive/macros/texinfo/texinfo/intl/config.charset
# Fri, 30 May 2003 00:09:00 GMT'
OS = Config::CONFIG["target"]
SHELL = Config::CONFIG['SHELL']
def charset_alias(config_charset, mapfile, target = OS)
map = {}
comments = []
IO.foreach("|#{SHELL} #{config_charset} #{target}") do |list|
next comments << list if /^\#/ =~ list
next unless /^(\S+)\s+(\S+)$/ =~ list
sys, can = $1, $2
next if sys == can
next if can.downcase! and sys == can
map[can] = sys
end
case target
when /linux|-gnu/
map.delete('ascii')
when /cygwin/
# get rid of tilde/yen problem.
map['shift_jis'] = 'cp932'
end
open(mapfile, "w") do |f|
f.puts("require 'iconv.so'")
f.puts
f.puts(comments)
f.puts("class Iconv")
map.each {|can, sys| f.puts(" charset_map['#{can}'.freeze] = '#{sys}'.freeze")}
f.puts("end")
end
end
(2..3) === ARGV.size or abort "usage: #$0 config.status map.rb [target]"
charset_alias(*ARGV)