next up previous
Next: SqueakToys Up: The Design and Implementation Previous: Keyboard Input


Reading and Writing Various File Format

The m17n Squeak supports a number of text file formats. The {\sf MultiByteFileStream} extends the feature of {\sf StandardFileStream}, and has capability to switch the file format it reads and writes.

{\sf MultiByteFileStream} has a instance variable called ``{\sf converter}.'' The family of methods for writing characters and strings eventually calls {\sf nextPut:} of {\sf MultiByteFileStream} and that method delegates the request to the converter's {\sf nextPut:toStream:} method. Similarly, the kernel of reading characters is the {\sf next} method and this method delegates the request to the converter's {\sf nextFromStream:} method.

Conceptually, all the converter object has to implement is those two methods. However, for proper {\sf peek} implementation, the stream has to be able to push back ``a character'' regardless the its actual size in the file. {\sf currentCharSize} of the converter returns the octet size for the last character read.

Currently, X Compound Text, GB2312, EUC-jp, EUC-kr, Shift-JIS, UTF-8 are supported.


Owner 2003-02-08