Subject: Re: [clisp-list] help about [ clisp-Bugs-550603 ] UTF-16 min/max_ bytes_per_char mu st be 2

From: "Hoehle, Joerg-Cyril" <[email-masked]>
Date: Thu May 2 07:56:44 2002

Hi,
> use CONVERT-STRING-TO-BYTES to get the appropriate byte array, then
> NULL-terminate it and turn into a foreign string.

> (length (convert-string-to-bytes string encoding))

My long mail was not clear enough.
How many 0 bytes to put at the end?

As I explained, a single 0 byte is not the answer for UTF-16, UCS-2, UNICODE-32 et al.

And (ext:convert-string-to-bytes (string (code-char 0)) #) doesn't yield the correct answer either, for all encodings (hint: try UTF-7 or UTF-16).

Regards,
	Jorg Hohle.

---

From: Sam Steingold <[email-masked]>
Date: Thu May 2 09:56:06 2002

> * In message <[email-masked]>
> * On the subject of "Re: [clisp-list] help about [ clisp-Bugs-550603 ] UTF-16 min/max_ bytes_per_char mu st be 2"
> * Sent on Thu, 2 May 2002 16:54:51 +0200
> * Honorable "Hoehle, Joerg-Cyril" <[email-masked]> writes:
>
just one.

> As I explained, a single 0 byte is not the answer for UTF-16, UCS-2, UNICODE-32 et al.

you must strip the NULL before converting the foreign string back to a
LISP string

NULL is a C artifact, it has no place in the LISP world.

recap:

take a lisp string.
convert it to bytes using any encoding.
append a NULL.
process as a C (ASCII, 8bit byte) string. [what use for C is the #(0 0 0 65)?!]
drop the last NULL byte. [what if it's not there anymore?]
convert back to LISP, using any encoding. [what if this fails?]

I am pretty I am missing something here.
It can't be that simple.

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat7.2 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.palestine-central.com/> <http://www.mideasttruth.com/>
Bus error -- please leave by the rear door.