emacs-devel
[Top][All Lists]
Advanced

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

Re: Is copy_string_contents in emacs-module.h give us a proper UTF-8 str


From: Robert Pluim
Subject: Re: Is copy_string_contents in emacs-module.h give us a proper UTF-8 string?
Date: Thu, 08 Oct 2020 09:40:02 +0200

>>>>> On Thu, 8 Oct 2020 14:09:53 +0800 (CST), "Zhu Zihao" 
>>>>> <all_but_last@163.com> said:

    Zhu> I see the comment in emacs-module.h says
    Zhu> /* Copy the content of the Lisp string VALUE to BUFFER as an utf8
    Zhu>      NUL-terminated string.

    Zhu>      SIZE must point to the total size of the buffer.  If BUFFER is
    Zhu>      NULL or if SIZE is not big enough, write the required buffer size
    Zhu>      to SIZE and return true.

    Zhu>      Note that SIZE must include the last NUL byte (e.g. "abc" needs
    Zhu>      a buffer of size 4).

    Zhu>      Return true if the string was successfully copied.  */

>From emacs-module.c:module_copy_string_contents:

     We set HANDLE-8-BIT and HANDLE-OVER-UNI to nil to signal an error
     if the argument is not a valid Unicode string.  While it isn't
     documented how copy_string_contents behaves in this case,
     signaling an error is the most defensive and obvious reaction. */

    Zhu> Will "copy_string_contents" always give us a proper UTF-8 string. Or 
it will give us a mix of bytevector and UTF8?

It will either give a UTF-8 string or signal an error.

Robert
-- 



reply via email to

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