Pattern matching non-English language characters
Hello all,
I am currently looking for a semi-elegant method of matching all letters that are not special language characters like ä, ë, ö, ü, etc. and have been having some trouble. At first I tried :gsub("%w", string.upper, 1) to replace the first letter of a string with a capital, however this caused any of the above special language characters to become "xx." I then tried string.sub(teststring, 1, 1) to get just the first character of a string, and it seems these special characters are using 2 (sometimes more?) characters, probably an escape code and a number, to render the actual symbol, so again, I ended up with just "x". Is there a way to have lua only match the first character in a string if it is a letter and NOT one of these special letters? |
I even tried this:
Code:
if string.sub(langtext, 1, 1) ~= "x" or "xx" then |
I figured it out... sort of.
I created a table (Alpha) with all standard alpha characters then did Code:
for k,v in pairs(Alpha) do |
My Argonian name is "Converses-With-Reflection." :D
|
http://lua-users.org/wiki/LuaUnicode
In standard Lua, it's not easy. There are a couple pure-Lua libraries there that you could use if you needed to for unicode pattern matching (and other string functions). |
All times are GMT -6. The time now is 11:02 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI