Handling various text file line-end conventions in VW
Labels:
Passport,
portability,
Smalltalk,
VisualWorks
Martin Kobetic has posted an excellent tutorial on handling different text file line-end conventions in VisualWorks.
The Passport inter-Smalltalk portability library (on which the Chronos Date/Time Library depends) also provides a solution to the same problem:
- UtilityFunction nextLineFrom: aStream
- UtilityFunction skipToNextLineOf: aStream
Passport does not provide any support for writing text files using different line-end conventions, for two reasons:
- The external WriteStreams provided by most Smalltalk implementations will already convert CR to the host platform's line-end convention.
- Given the ability to read text files correctly, regardless of line-end convetion, there is not as much need to be able to write files with any particular line-end convention.
Chronos uses both of the above Passport functions in order to read time zone and other information from text files stored in the Chronos Time Zone Repository. Using those two Passport functions not only provides Chronos with inter-Smalltalk portability, it also means that a single version of the Chronos Time Zone Repository can be used on all host platforms, even when the text files were generated on a different operating system.
No comments:
Post a Comment