BRL.TextStream: Functions Source  


The Text Stream module allows you to load and save text in a number of formats: LATIN1, UTF8 and UTF16.

The LATIN1 format uses a single byte to represent each character, and is therefore only capable of manipulating 256 distinct character values.

The UTF8 and UTF16 formats are capable of manipulating up to 1114112 character values, but will generally use greater storage space. In addition, many text processing applications are unable to handle UTF8 and UTF16 files.

Functions

LoadTextLoad text from a stream
SaveTextSave text to a stream

Function reference

Function LoadText$( url:Object )
ReturnsA string containing the text
DescriptionLoad text from a stream
Information LoadText loads LATIN1, UTF8 or UTF16 text from url.

The first bytes read from the stream control the format of the text:
&$fe $ffText is big endian UTF16
&$ff $feText is little endian UTF16
&$ef $bb $bfText is UTF8

If the first bytes don't match any of the above values, the stream is assumed to contain LATIN1 text.

A TStreamReadException is thrown if not all bytes could be read.

Function SaveText( str$,url:Object )
DescriptionSave text to a stream
Information SaveText saves the characters in str to url.

If str contains any characters with a character code greater than 255, then str is saved in UTF16 format. Otherwise, str is saved in LATIN1 format.

A TStreamWriteException is thrown if not all bytes could be written.