Thread Tools Display Modes
04/27/15, 07:11 PM   #1
Phinix
 
Phinix's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 186
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?
  Reply With Quote
04/27/15, 07:34 PM   #2
Phinix
 
Phinix's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 186
I even tried this:

Code:
if string.sub(langtext, 1, 1) ~= "x" or "xx" then
	langtext = langtext:gsub("%w", string.upper, 1)
end
Still just ends up x's.
  Reply With Quote
04/27/15, 08:16 PM   #3
Phinix
 
Phinix's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 186
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
	if string.sub(langtext, 1, 1) == v then
		langtext = langtext:gsub("%w", string.upper, 1)
		break
	end
end
  Reply With Quote
04/27/15, 08:47 PM   #4
Phinix
 
Phinix's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 186
My Argonian name is "Converses-With-Reflection."
  Reply With Quote
04/27/15, 08:54 PM   #5
Sasky
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 231
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).
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Pattern matching non-English language characters


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off