Is there, uh, string.upper for symbols?

I’ve made a custom textbox. I’m trying to uh… capitalize(?) symbols. I can capitalize normal letters, (a, b, c) but not symbols. By capitalize, I mean pressing shift and the symbol. I’m using string.upper, but that doesn’t work for symbols. Is there any function that capitalizes symbols and letters? Thanks.

By symbols, do you mean letters like Å, Ç, etc.?

1 Like

No, not those kind of symbols. I mean like ~!@#$%^&*()_+{}|:"<>?

Shift + 1
Shift + 2
Shift + 3

etc

The problem is, that not every keyboard has the same shift symbols.

2 Likes

Would it be possible for you to have an invisible TextBox and copy whatever is typed into it, onto your custom TextBox?

1 Like

That sounds like something you’d need to implement yourself. AFAIK, string.upper works in the conceptual sense of capitalizing a letter. You can’t use it to conform to what your keyboard uses with shift. You’ll probably need to just make a table that maps all the symbols you want to “capitalize”

local Map = {
    ["1"] = "!",
    ["2"] = "@",
     -- rest of symbols
}
1 Like

use a table that does regular symbols with their shifted version like 1 etc

local symbolMap = {
    ['1'] = '!', ['2'] = '@', ['3'] = '#', ['4'] = '$', ['5'] = '%',
    ['6'] = '^', ['7'] = '&', ['8'] = '*', ['9'] = '(', ['0'] = ')',
    ['-'] = '_', ['='] = '+', ['['] = '{', [']'] = '}', ['\\'] = '|',
    [';'] = ':', ['\''] = '"', [','] = '<', ['.'] = '>', ['/'] = '?',
    ['`'] = '~'
}

local function capitalizeAll(text)
    local result = ""
    for i = 1, #text do
        local char = text:sub(i, i)
        if symbolMap[char] then
            result = result .. symbolMap[char]
        else
            result = result .. string.upper(char)
        end
    end
    return result
end
-- example 
local testString = "Hello123!@#"
local result = capitalizeAll(testString)
print("Original: " .. testString)
print("Capitalized: " .. result)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.