This library contains one OmniMark external source function and one OmniMark external output function implementation for converting from and to the "JIS" encoding of Japanese text, as follows:
readeris an external source function that reads a value string source, its argument, and returns the text of that file converted from a JIS encoding to a UTF-8 encoding. That is, the provided source is in JIS, but the program sees UTF-8.
writeris an external output function that accepts UTF-8 encoded data and writes that data to a value string sink, its first argument, converted from a UTF-8 encoding to a JIS encoding. That is, the program writes UTF-8, but the provided output receives JIS.
writer has an optional first argument, heralded by
encoding-sequence, that is the escape sequence used to switch into two-byte JIS X 0208/JIS C 6226 mode. It must be at least one byte long and must be no more than eight bytes long.
The data formats are interpreted/produced according to the Japanese Industry Standards JIS X 0201, JIS X 0208 and JIS X 0212. The JIS data format uses ISO 2022 (a.k.a. JIS X 0202) based escape sequences to shift between the encodings defined by the three standards. On input, some laxity is shown in recognizing not-quite-valid escape sequences and those defined by older versions of the standards, meaning that it should do a good job on a variety of input files. On output, the escape sequences defined by the latest versions of the standards are used.
The module exports the following constants, which specify the version of the standard being used.
The only kinds of errors that can occur are in conversion: finding a character that doesn't have a conversion in the other character set. In this case, the converted value use is DEL (0x7F) in the JIS encoding, and NOT-A-CHARACTER (0xFFFD) in the Unicode (UTF-8) encoding.
These functions are based on the book "Understanding Japanese Information Processing" by Ken Lunde, O'Reilly 1993, ISBN 1-56592-043-0, with one exception: the use of shift-out/shift-in for switching to and from half-width Katakana characters follows Ken Lunde's errata at <ftp://ftp.ora.com/pub/examples/nutshell/ujip/errata/ujip-errata-1-3.txt>, rather than what the book has on page 70 (which has the JIS7 and JIS8 forms switched around with respect to this issue).
To use omffjis, you must import it into your program using a statement like this:
import "omffjis.xmd" prefixed by jis.
(Please see the
for more on importing.)