Updated 2012-09-07 01:14:53 by RLE

Richard Suchenwirth 2000-03-17 -- Want to produce internationalized HTML documents with little effort? Having transliterators from The Lish family, you can write HTML with embedded foreign language sections (e.g. Arabic) in transliteration like this
 <HTML><HEAD></HEAD><BODY>
 Germany   [ar AlmAnyA]
 </BODY></HTML>

and feed the resulting file through lish2html below. The resulting file looks like
 <HTML><HEAD></HEAD><BODY>
 Germany   ﺎﻴﻧﺎﻤﻟﺍ
 </BODY></HTML>

Not exactly readable, but the HTML way to express Unicodes. Given a browser that accepts Unicodes (turned on e.g. Netscape 4.6 with View/Character set/Unicodes (UTF-8)) and has a font that contains the wanted characters, bingo! Arabic on your web page.

This script substitutes what it can, not only [..] calls, but $.. and \u.... as well. When something goes wrong in one source line, that line is sent unchanged to output.
 #!/bin/sh
 # -*-Tcl-*- Time-stamp: "lish2html: 2000-03-17,14:36:24 ([email protected])" \
 exec tclsh8.3 "$0" ${1+"$@"}

 # assume the required *lish files are in the same directory as this
 # modify to anything fancier if needed 

 set this [file join [pwd] [info script]]
 if ![catch {file readlink $this} res] {set this $res}
 lappend auto_path [file dirname $this]

 ;proc usage {} {
        puts "usage: lish2html \[infile \[outfile\]\]
 Substitutes *lish phrases to &#nnnn; HTML Unicodes"
 }
 ;proc u2html {s} {
    set res ""
    foreach u [split $s ""] {
        scan $u %c t
        if {$t>127} {
            append res "&#$t;"
        } else {
            append res $u
        }
    }
    set res
 } ;# RS
 #------------------------------------ main routine
 set infile stdin
 set outfile stdout
 set argc [llength $argv]
 if {$argc>2} {usage; exit}
 if {$argc} {
    set inname [lindex $argv 0]
    if {![file readable $inname]} {
        usage; exit
    }
    set infile [open $inname r]
    if {$argc==2} {
        set outfile [open [lindex $argv 1] w]
    }
 }
 while {[gets $infile line]>=0} {
    if [catch {u2html [subst $line]} res] {
        puts $outfile $line
    } else {
        puts $outfile $res
    }
 }
 if {$outfile!="stdout"} {close $outfile}