I made 3 functions for strings.
Also, yes, I know this post is a year old, and that it was already answered, but I still made a function for you.
(And I already know that uppercase and lowercase methods exist but I don't care.)
function toUppercase(originalString, printString)
if printString ~= true and printString ~= false then
printString = false
end
if printString == true then
print(originalString:upper())
else
return originalString:upper()
end
end
function toLowercase(originalString, printString)
if printString ~= true and printString ~= false then
printString = false
end
if printString == true then
print(originalString:lower())
else
return originalString:lower()
end
end
function toTitleCase(originalString, printString)
if printString ~= true and printString ~= false then
printString = false
end
changeString = originalString:gsub("%W%l", string.upper):sub(0)
titleCase = changeString:sub(1, 1):upper() .. changeString:sub(2, #changeString)
if printString == true then
print(titleCase)
else
return titleCase
end
end
s="ö" ; s:byte(1) == 195 ; s:byte(2) == 164
– Cydnusstring.sub()
also doesn't work for unicode :-) – Cydnuss1 = s:match"^.?[\128-\191]*"
– Hawfinch