lua-users home
lua-l archive

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


> On 29 Jun 2017, at 03:18, Niccolo Medici <niccolomedici@gmail.com> wrote:
> 
>> On 6/28/17, Duane Leslie <parakleta@darkreality.org> wrote:
>> Hi,
>> 
>> I had a problem with the quoted string format producing strings that
>> were not legal UTF-8 [...]
> 
> What do you mean? I don't see any problem:
> 
> `string.format("%q", "Здравствуйте")` returns '"Здравствуйте"'. That's
> valid UTF-8.

Attached is a UTF-8 aware version of the `addquoted` function.  I'm not sure if it really fits given that the UTF-8 behaviour is attached to a different library, but it might be useful to someone and it's better than my last proposal.

Also, I have noticed that the `utf8_decode` function passes the UTF-16 surrogates which are illegal codepoints, so this might also need to be fixed.

Regards,

Duane.

Attachment: addquoted.c
Description: Binary data