Lua String.upper does not use stress characters?

I am trying to convert some French text to uppercase letters in lua, it will not convert accented characters. Do you know why?

Test script:

print(‘échelle’)
print(string.upper(‘échelle’))
print(‘ÉCHELLE’)
print(string.lower(‘ÉCHELLE’))

Output:

échelle
éCHELLE
ÉCHELLE
Échelle

It may be overkill, but you can do it with slnunicode (available in LuaRocks).

require "unicode"
print(unicode. utf8.upper("échelle"))
-- ÉCHELLE

You may need to use unicode.ascii.upper or unicode.latin1.upper, depending on the encoding of the source file.

I am trying to convert some French text to uppercase letters in lua, it will not convert accented characters. Any idea why?

Test script:

print(‘échelle’)
print(string.upper(‘échelle’))
print(‘ÉCHELLE’)
print(string.lower(‘ÉCHELLE’))

Output:

échelle
éCHELLE
ÉCHELLE
Échelle

It may be a bit overkill, but you can use slnunicode(LuaRocks Available in) to do this.

require "unicode"
print(unicode.utf8.upper("échelle"))
-- ÉCHELLE

You may need to use unicode.ascii.upper or unicode.latin1.upper, depending on the encoding of the source file.

Leave a Comment

Your email address will not be published.