Thread Tools Display Modes
Prev Previous Post   Next Post Next
09-27-22, 03:43 PM   #1
casualfetzer
A Defias Bandit
Join Date: Sep 2022
Posts: 3
Weird issues with string.match and encoding (I think)

Hey,

I'm trying to do some string pattern matching to pull out an m+ key level from the description from a Group Finder posting. However the matching seems to get some fairly odd results

Here is a snippet of the code from within a hook function registered to the LFGListSearchEntry_Update event

Code:
function DWMShook_LFGListSearchEntry_Update(entry, ...)

    local name = entry.Name:GetText() or "";

    local key_level = strmatch(name, "(%d+)")
    --Show the matched string and the original string it was matched from
    print(format("%s - key_level, %s - name", key_level, name))

    --Check strmatch functionality on string literal (i.e. not string from
    --Blizzard API
    print(strmatch("+21", "(%d+)"))

end
And this outputs
Code:
445 - key_level, +15 - name
21
I've read somehwere that all strings returned from Blizz APIs are encoded as UTF-8 and I guess this might be causing an issue due to the variable width of the character codes in UTF-8. Anyone come across this kind of issue before is there something super obvious I am missing. Feels like I'm missing something or that I'm doing something dumb (or both)

Cheers,
Fetzer
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Weird issues with string.match and encoding (I think)


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