|
|||||||||
|
|||||||||
Functions | Platforms | ||||||||
utf8pat - UTF-8 text processing |
The UTF-8 encoding library allows you to process data files that contain UTF-8 encoding.
You can use the pattern macro utf8-char
to match UTF-8 characters in data.
You can use the function utf8-char-number
to convert a UTF-8 character (that is, a sequence of bytes that represents a character in UTF-8) to its binary character value.
You can use the function utf8-encoded
to convert a binary character value to UTF-8 (that is, to that sequence of bytes which represents that character value in UTF-8).
The following is an example of a translate rule that uses the UTF-8 encoding library to convert UTF-8 characters in a string to their binary character code equivalents. It outputs characters in the ASCII range as ordinary ASCII codes, and characters outside the ASCII range as XML numerical character references:
include "utf8pat.xin" process repeat scan "flamb%195#%169#" match ["%0#" to "%127#"]+ => c output c match utf8-char => c local integer n set n to utf8-char-number c do when n > 255 output "&#x" || "16rud" % n || ";" else output "b" % n done again
To use these functions, you must include the following code near the top of your program:
include "utf8pat.xin"
Functions utf8-char utf8-char-number utf8-encoded |
Platforms Digital UNIX (Alpha) HP/UX IBM AIX Linux (Intel) MS Windows 95/98 MS Windows NT SGI IRIX SINIX Sun Solaris |
---- |