charset_alias.rb

Path: iconv/charset_alias.rb
Last Update: Sat Dec 13 20:55:21 GMT+10:00 2003

Required files

rbconfig  

Methods

Constants

OS = Config::CONFIG["target"]
  www.ctan.org/tex-archive/macros/texinfo/texinfo/intl/config.charset Fri, 30 May 2003 00:09:00 GMT‘
SHELL = Config::CONFIG['SHELL']

Public Instance methods

[Source]

# File iconv/charset_alias.rb, line 23
def charset_alias(config_charset, mapfile, target = OS)
  map = Hash::Ordered.new
  comments = []
  IO.foreach("|#{SHELL} #{config_charset} #{target}") do |list|
    next comments << list if /^\#/ =~ list
    next unless /^(\S+)\s+(\S+)$/ =~ list
    sys, can = $1, $2
    can.downcase!
    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

[Validate]