gpt4 book ai didi

lua string.upper 不使用重音字符?

转载 作者:行者123 更新时间:2023-12-04 18:47:39 25 4
gpt4 key购买 nike

我试图在 lua 中将一些法语文本转换为大写,它没有转换重音字符。知道为什么吗?

测试脚本:

print('échelle')
print(string.upper('échelle'))
print('ÉCHELLE')
print(string.lower('ÉCHELLE'))



输出:

échelle
éCHELLE
ÉCHELLE
Échelle

最佳答案

这可能有点矫枉过正,但你可以用 slnunicode 做到这一点。 (在 LuaRocks 中可用)。

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

您可能需要使用 unicode.ascii.upperunicode.latin1.upper取决于源文件的编码。

关于lua string.upper 不使用重音字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11571951/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com