[Top] [Prev] [Next] [Bottom]


[Contents] [Index]

utfbytes - compute the Unicode length of a UTF byte sequence

utfbytes: fn(buf: array of byte, n: int): int;
## returns the number of bytes in buf that represent valid 
Unicode characters.

Description

The utfbytes function examines the n -byte UTF sequence starting at buf [0] and returns the number of bytes, if any, that represent a single Unicode character. The end of the array may contain an incomplete UTF sequence without affecting the return value.

Caveat

A call to utfbytes can generate a bounds check error, if the length argument is larger than the array itself.

Example

This fragment reports the number of bytes in the first command line argument that represent single Unicode characters:

buf := array of byte hd tl argv;
nbytes := sys->utfbytes(buf, len buf);
sys->print("nbytes= %d\n", nbytes);

See Also

System Module Overview
byte2char, char2byte - conversion functions
UTF, Unicode, ASCII - character set and format in Appendix A


[Top] [Prev] [Next] [Bottom]

infernosupport@lucent.com
Copyright © 1997, Lucent Technologies, Inc.. All rights reserved.