summaryrefslogtreecommitdiff
path: root/support/rfil/examples/encodingtable
diff options
context:
space:
mode:
Diffstat (limited to 'support/rfil/examples/encodingtable')
-rwxr-xr-xsupport/rfil/examples/encodingtable67
1 files changed, 67 insertions, 0 deletions
diff --git a/support/rfil/examples/encodingtable b/support/rfil/examples/encodingtable
new file mode 100755
index 0000000000..59c12d459d
--- /dev/null
+++ b/support/rfil/examples/encodingtable
@@ -0,0 +1,67 @@
+#!/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 <patrick@gundla.ch>
+=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