#!/usr/bin/env ruby -w #-- # Last Change: Tue May 16 18:11:49 2006 #++ =begin rdoc = encodingtable -- print out a table with different encodings in colums This is mainly an example how to use the ENC and Kpathsea class. == Usage encodingtable encoding[.enc] [encoding[.enc] ...] == Example $ ./encodingtable ec texnansi 8r 8a dec | oct |hex | ECEncoding | TeXnANSIEncoding | TeXBase1Encoding | StandardEncoding | -------------------------------------------------------------------------------------------- 0 | 0 | 0 | grave | --- | --- | --- | 1 | 1 | 1 | acute | Euro | dotaccent | --- | 2 | 2 | 2 | circumflex | --- | fi | --- | 3 | 3 | 3 | tilde | --- | fl | --- | 4 | 4 | 4 | dieresis | fraction | fraction | --- | 5 | 5 | 5 | hungarumlaut | dotaccent | hungarumlaut | --- | ... --- Author:: Patrick Gundlach =end # :enddoc: require 'rfil/tex/enc' require 'rfil/tex/kpathsea' include RFIL include TeX unless ARGV.size > 0 puts "Usage: #{File.basename($0)} encoding[.enc] ..." exit end fmt=" %-16.16s |" encodings=[] kpse=Kpathsea.new ARGV.each { |e| kpse.open_file(e.chomp('.enc')+'.enc','enc') { |f| encodings.push(ENC.new(f)) } } print "dec | oct |hex |" encodings.each { |e| print sprintf(fmt,e.encname) } 0.upto(255) { |slot| print "\n"+"-"*(16 + encodings.size * 19 ) if slot % 32 == 0 print sprintf("\n%3d | %3o | %2x |", slot,slot,slot) encodings.each { |e| print sprintf(fmt, e[slot]==".notdef" ? "---" : e[slot]) } } puts