Accented letters returning invalid character

Asked

Viewed 114 times

6

Well, I realized that in Lua, you can’t use accented letters.

print("á")

Returns an invalid character. Is there any way to avoid this?

  • 2

    What system are you using? This is much more related to your system than the language itself. For example if you test in Codepad or even in some calculators with Lua support you will get the way you want: á

1 answer

10


It is totally possible, but you need to define the appropriate locale. For this you can make use of the function os.setlocale (locale \[, category\]) that will set the locale for the program:

Example:

os.setlocale("pt_PT")

or

os.setlocale("pt_PT.iso88591")

You can see the example on Ideone.

If none is defined, the system one is used.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.