Test script:
print(‘échelle’)
print(string.upper(‘échelle’))
print(‘ÉCHELLE’)
print(string.lower(‘ÉCHELLE’))
Output:
échelle
éCHELLE
ÉCHELLE
Échelle
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.