Version 2 of Things Japanese

Updated 2001-11-14 20:08:39

Purpose: collect Tcl code specific to the Japanese culture. Part of a series that started with Things British


Nengo calculation: The Japanese calendar starts counting years from 1 with each accession of an emperor, who baptizes his era with a two-Kanji name, nengo (see for example http://japanesesword.homestead.com/files/kanji/nengo.htm ). The following nengo are important for recent times:

 Meiji  1868-1911
 Taisho 1912-1925
 Showa  1926-1988
 Heisei 1989-

For these four eras (and four more free positions), Unicodes have been allocated that render both Kanji into one character. (One might of course also render the two separately, from the regular CJK set). The windows font "Arial Unicode MS" has these four characters, so the following code was possible:

 proc nengo {{year ""}} {
    # convert an AD year (default: this) to nengo style 
    if {$year==""} {set year [clock format [clock seconds] -format %Y]}
    if {$year<1868} {
        error "cannot convert year $year, prior to 1868"
    } elseif {$year<1912} {
        incr year -1867; set nengo \u337E ;# Meiji
    } elseif {$year < 1926} {
        incr year -1911; set nengo \u337D ;# Taisho
    } elseif {$year < 1989} {
        incr year -1925; set nengo \u337C ;# Showa
    } else {
        incr year -1988; set nengo \u337B ;# Heisei
    }
    return $nengo$year
 } ;# RS

Japlish: a functional converter from Romaji (7-bit ASCII letters for hiragana and KATAKANA, the two syllabic writing systems used in Japan) to the corresponding Unicodes, plus a handful of Kanji words - add more if you need them...


i18n - writing for the world - Arts and crafts of Tcl-Tk programming