大小写转换

基本类型 / 字符串

local text = "Lower And Upper"

local lower = text:lower()
-- lower = lower and upper

local upper = text:upper()
-- upper = LOWER AND UPPER

-- 没有 capitalize:首字母大写,其余小写
local capitalize = text:sub(1, 1):upper()
                   .. text:sub(2):lower()
-- capitalize = Lower and upper

-- 只有 ASCII 字母会变化,\u{E9} 保持原样
local accent = "\u{E9}"
local still_lower = accent:upper() == accent
-- still_lower = true

print("lower = " .. lower)
print("upper = " .. upper)
print("capitalize = " .. capitalize)
print("still_lower = " .. tostring(still_lower))