Libraries
Utf16 Source Code
 previous   up   next 

Types
utf16File
File implementation type for UTF-16 files.
utf16leFile
File implementation type for UTF-16LE (little endian) files.
utf16beFile
File implementation type for UTF-16BE (big endian) files.

utf16File

const type: utf16File

File implementation type for UTF-16 files. This type supports UTF-16 encoded sequential files of the operating system. UTF-16 files are seekable, therefore they support the functions length, seek and tell.


utf16leFile

const type: utf16leFile

File implementation type for UTF-16LE (little endian) files. This type supports UTF-16 encoded sequential files of the operating system. UTF-16 files are seekable, therefore they support the functions length, seek and tell.


utf16beFile

const type: utf16beFile

File implementation type for UTF-16BE (big endian) files. This type supports UTF-16 encoded sequential files of the operating system. UTF-16 files are seekable, therefore they support the functions length, seek and tell.


Function Summary
void
close (in utf16File: aFile)
Close an utf16File.
void
flush (in utf16File: outFile)
Forces that all buffered data of outFile is sent to its destination.
boolean
eof (in utf16File: inFile)
Determine the end-of-file indicator.
boolean
hasNext (in utf16File: inFile)
Determine if at least one character can be read successfully.
integer
length (in utf16File: aFile)
Obtain the length of a file.
void
truncate (in utf16File: aFile, in integer: length)
Truncate aFile to the given length.
boolean
seekable (in utf16File: aFile)
Determine if the file aFile is seekable.
void
seek (in utf16File: aFile, in integer: position)
Set the current file position.
integer
tell (in utf16File: aFile)
Obtain the current file position.
file
openUtf16le (in string: path, in string: mode)
Opens an Unicode file which uses the UTF-16LE encoding.
void
write (in utf16leFile: outFile, in string: stri)
Write a string to an UTF-16LE file.
string
gets (in utf16leFile: inFile, in integer: maxLength)
Return a string read with a maximum length from an UTF-16LE file.
file
openUtf16be (in string: path, in string: mode)
Opens an Unicode file which uses the UTF-16BE encoding.
void
write (in utf16beFile: outFile, in string: stri)
Write a string to an UTF-16BE file.
string
gets (in utf16beFile: inFile, in integer: maxLength)
Return a string read with a maximum length from an UTF-16BE file.
file
openUtf16 (in string: path, in string: mode)
Opens an Unicode file which uses the UTF-16LE or UTF-16BE encoding.

Function Detail

close

const proc: close (in utf16File: aFile)

Close an utf16File.

Raises:
FILE_ERROR - A system function returns an error.

flush

const proc: flush (in utf16File: outFile)

Forces that all buffered data of outFile is sent to its destination. This causes data to be sent to the operating systems file system.


eof

const func boolean: eof (in utf16File: inFile)

Determine the end-of-file indicator. The end-of-file indicator is set if at least one request to read from the file failed.

Returns:
TRUE if the end-of-file indicator is set, FALSE otherwise.

hasNext

const func boolean: hasNext (in utf16File: inFile)

Determine if at least one character can be read successfully. This function allows a file to be handled like an iterator.

Returns:
FALSE if 'getc' would return EOF, TRUE otherwise.

length

const func integer: length (in utf16File: aFile)

Obtain the length of a file. The file length is measured in bytes.

Returns:
the size of the given file.
Raises:
RANGE_ERROR - The file length does not fit into an integer value.
FILE_ERROR - A system function returns an error or the file length reported by the system is negative.

truncate

const proc: truncate (in utf16File: aFile, in integer: length)

Truncate aFile to the given length. If the file previously was larger than length, the extra data is lost. If the file previously was shorter, it is extended, and the extended part is filled with null bytes ('\0;').

Parameters:
aFile - File to be truncated.
length - Requested length of aFile in bytes.
Raises:
RANGE_ERROR - The requested length is negative or the length is not representable in the type used by the system function.
FILE_ERROR - A system function returns an error.

seekable

const func boolean: seekable (in utf16File: aFile)

Determine if the file aFile is seekable. If a file is seekable the functions seek and tell can be used to set and and obtain the current file position.

Returns:
TRUE, if aFile is seekable, FALSE otherwise.

seek

const proc: seek (in utf16File: aFile, in integer: position)

Set the current file position. The file position is measured in bytes from the start of the file. The first byte in the file has the position 1.

Raises:
RANGE_ERROR - The file position is negative or zero.
FILE_ERROR - A system function returns an error.

tell

const func integer: tell (in utf16File: aFile)

Obtain the current file position. The file position is measured in bytes from the start of the file. The first byte in the file has the position 1.

Returns:
the current file position.
Raises:
RANGE_ERROR - The file position does not fit into an integer value.
FILE_ERROR - A system function returns an error or the file position reported by the system is negative.

openUtf16le

const func file: openUtf16le (in string: path, in string: mode)

Opens an Unicode file which uses the UTF-16LE encoding. The file is opened with the specified path and mode. If the file is opened with one of the modes "w", "w+", "wt" or "wt+" an appropriate BOM is created. If the file is opened with a any other mode the application program is in charge to handle optional BOM markers. This way 'openUtf16le' can be used to open existing files without BOM. There are text modes and binary modes:

  • Binary modes:
    • "r" Open file for reading.
    • "w" Truncate to zero length or create file for writing.
    • "a" Append; open or create file for writing at end-of-file.
    • "r+" Open file for update (reading and writing).
    • "w+" Truncate to zero length or create file for update.
    • "a+" Append; open or create file for update, writing at end-of-file.
  • Text modes:
    • "rt" Open file for reading.
    • "wt" Truncate to zero length or create file for writing.
    • "at" Append; open or create file for writing at end-of-file.
    • "rt+" Open file for update (reading and writing).
    • "wt+" Truncate to zero length or create file for update.
    • "at+" Append; open or create file for update, writing at end-of-file.

Note that this modes differ from the ones used by the C function fopen().

Parameters:
path - Path of the file to be opened. The path must use the standard path representation.
mode - Mode of the file to be opened.
Returns:
the file opened, or STD_NULL if it could not be opened or if path refers to a directory.
Raises:
MEMORY_ERROR - Not enough memory to convert the path to the system path type.
RANGE_ERROR - The mode is not one of the allowed values or path does not use the standard path representation or path cannot be converted to the system path type.

write

const proc: write (in utf16leFile: outFile, in string: stri)

Write a string to an UTF-16LE file.

Raises:
RANGE_ERROR - A character is not representable with UTF-16.
FILE_ERROR - The system function returns an error.

gets

const func string: gets (in utf16leFile: inFile, in integer: maxLength)

Return a string read with a maximum length from an UTF-16LE file.

Returns:
the string read.
Raises:
RANGE_ERROR - The parameter maxLength is negative, or the file contains an invalid surrogate pair.

openUtf16be

const func file: openUtf16be (in string: path, in string: mode)

Opens an Unicode file which uses the UTF-16BE encoding. The file is opened with the specified path and mode. If the file is opened with one of the modes "w", "w+", "wt" or "wt+" an appropriate BOM is created. If the file is opened with a any other mode the application program is in charge to handle optional BOM markers. This way 'openUtf16be' can be used to open existing files without BOM. There are text modes and binary modes:

  • Binary modes:
    • "r" Open file for reading.
    • "w" Truncate to zero length or create file for writing.
    • "a" Append; open or create file for writing at end-of-file.
    • "r+" Open file for update (reading and writing).
    • "w+" Truncate to zero length or create file for update.
    • "a+" Append; open or create file for update, writing at end-of-file.
  • Text modes:
    • "rt" Open file for reading.
    • "wt" Truncate to zero length or create file for writing.
    • "at" Append; open or create file for writing at end-of-file.
    • "rt+" Open file for update (reading and writing).
    • "wt+" Truncate to zero length or create file for update.
    • "at+" Append; open or create file for update, writing at end-of-file.

Note that this modes differ from the ones used by the C function fopen().

Parameters:
path - Path of the file to be opened. The path must use the standard path representation.
mode - Mode of the file to be opened.
Returns:
the file opened, or STD_NULL if it could not be opened or if path refers to a directory.
Raises:
MEMORY_ERROR - Not enough memory to convert the path to the system path type.
RANGE_ERROR - The mode is not one of the allowed values or path does not use the standard path representation or path cannot be converted to the system path type.

write

const proc: write (in utf16beFile: outFile, in string: stri)

Write a string to an UTF-16BE file.

Raises:
RANGE_ERROR - If a character is not representable with UTF-16.
FILE_ERROR - The system function returns an error.

gets

const func string: gets (in utf16beFile: inFile, in integer: maxLength)

Return a string read with a maximum length from an UTF-16BE file.

Returns:
the string read.
Raises:
RANGE_ERROR - The parameter maxLength is negative, or the file contains an invalid surrogate pair.

openUtf16

const func file: openUtf16 (in string: path, in string: mode)

Opens an Unicode file which uses the UTF-16LE or UTF-16BE encoding. The file is opened with the specified path and mode. The function 'openUtf16' checks for a BOM and depending on that opens an UTF-16LE or UTF-16BE file. If the file contains no BOM the function returns STD_NULL. There are text modes and binary modes:

  • Binary modes:
    • "r" Open file for reading.
    • "w" Truncate to zero length or create file for writing.
    • "a" Append; open or create file for writing at end-of-file.
    • "r+" Open file for update (reading and writing).
    • "w+" Truncate to zero length or create file for update.
    • "a+" Append; open or create file for update, writing at end-of-file.
  • Text modes:
    • "rt" Open file for reading.
    • "wt" Truncate to zero length or create file for writing.
    • "at" Append; open or create file for writing at end-of-file.
    • "rt+" Open file for update (reading and writing).
    • "wt+" Truncate to zero length or create file for update.
    • "at+" Append; open or create file for update, writing at end-of-file.

Note that this modes differ from the ones used by the C function fopen().

Parameters:
path - Path of the file to be opened. The path must use the standard path representation.
mode - Mode of the file to be opened.
Returns:
the file opened, or STD_NULL if it could not be opened or if path refers to a directory.
Raises:
MEMORY_ERROR - Not enough memory to convert the path to the system path type.
RANGE_ERROR - The mode is not one of the allowed values or path does not use the standard path representation or path cannot be converted to the system path type.


 previous   up   next