gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Inquiring about the status of the proposed UNICODE library


From: Alice Osako
Subject: Re: Inquiring about the status of the proposed UNICODE library
Date: Sun, 10 Mar 2024 10:07:55 -0400
User-agent: Mozilla Thunderbird

Benjamin Kowarsch:
Basically you need two functions

PROCEDURE utf8ToUnichar ( utf8 : ARRAY [0..5] OF CARDINAL [0..127]; VAR ch : UNICHAR );

PROCEDURE unicharToUtf8 ( ch : UNICHAR; VAR utf8 : ARRAY [0..5] OF CARDINAL [0..127] );

I just noticed that I made a mistake in the above function signatures. For UTF-8, the I/O buffer elements should be of type CARDINAL [0..255] instead of CARDINAL [0..127]. The latter would be for UTF-7.

Ah, that makes sense.

BTW, for portability, you should avoid using SHORTCARD. Define a type for CARDINAL [0..255]. This will be portable.

Oh, excellent point, thank you.

You may also need a few utility functions such as:

PROCEDURE UCHR ( n : CARDINAL ) : UNICHAR;
(* Returns a UNICHAR value for code point n *)

PROCEDURE is7bitPrintable ( ch : UNICHAR ) : BOOLEAN;
(* Returns TRUE if ch represents a 7-bit printable character, else FALSE *)

PROCEDURE charFromUnichar ( ch : UNICHAR ) : CHAR;
(* Converts a UNICHAR value to type CHAR if ch is a 7-bit printable,
    causes a runtime error if ch does not represent a 7-bit printable *)

If you design the library for unqualified import, you may call the latter function toChar, calling it as Unichar.toChar().

Ah, thank you very much, this helps tremendously.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]