lua-users home
lua-l archive

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


2017-05-02 7:32 GMT+02:00 Ahmed Charles <acharles@outlook.com>:
> On 5/1/2017 3:27 PM, Luiz Henrique de Figueiredo wrote:
>>> print("á")
>>>
>>> When encoded as UTF-8.
>>>
>>> Looking at the manual, I can't tell whether this is intentional or not.
>>> The program, when executed, does seem to function as expected. Can you
>>> clarify if this program is intended to be valid Lua?
>>
>> Calling print with any string is valid Lua. What you see depends on what
>> the string contains and, more to the point, on how the terminal you use
>> interprets the contents of the string. Lua is actually completely agnostic
>> about the contents of a string: strings are just sequence of bytes.
>>
>> So, yes, A Lua program that uses UTF-8 text in Lua strings will work just
>> fine, provided you only do I/O with them. The standard string library
>> does not work on UTF-8 text. The standard utf8 library helps but does not
>> replace the standard string library.
>
> I guess my question wasn't clear enough. I didn't mean to focus on the
> print call. I meant to ask whether UTF-8 in comments is intended and
> whether UTF-8 in string literals is intended?

The current situation is that comments and strings are byte sequences
and anything is legal inside them.

If it looks like UTF-8 on your screen, that is because the current setting
of your locale or your clever text editor or mail client makes it look so.
At least one  member of this list and I suspect several others still uses
ISO-8859-1 in e-mails and probably their comments and strings would be
ISO-8859-1 too. Note that any program that expects ISO-8859 is not fazed
by UTF-8, it just displays it wrong, whereas a program that expects UTF-8
and gets ISO-8859 is confused.