View Single Post
04/20/20, 08:37 AM   #4
Drummerx04
AddOn Author - Click to view addons
Join Date: Sep 2017
Posts: 54
Oh yeah, I've ran into plenty of weird behaviors when dealing with utf8 in ESO. I haven't messed with it for about a year, but when trying to write a match expression for international characters in profile names, I tried something like this.
Lua Code:
  1. for match in testString:gmatch("@[a-zA-Z0-9_\128-\255]+")
The string library in lua/ESO only works on single byte characters, so what this actually does is assumes that any byte over \127 is part of a valid utf8 multibyte character, and for my purposes that would have been perfectly fine.

The issue is that it DIDN'T WORK. The \128-\255 expression was ignored (but something like \97-\123 was matched correctly as a-z).

Even more interestingly I came up with an alternative approach which DOES work
Lua Code:
  1. for match in testString:gmatch("(@[^\1-\47\58-\64\91-\96]+)") do
Basically, just create a character set you DON'T want and then invert it with '^'

I don't remember the utf8 module being in ESO, maybe that was added after I left, but if they didn't fix their regex parser ignoring any character value over \127, then you'd have more problems anyway.

Last edited by Drummerx04 : 04/20/20 at 11:25 AM.
  Reply With Quote