Can not get chinese charactors by new function of WeakAuras.GetMHTenchInfo()
roundzero opened this issue ยท 4 comments
Description
After typing /dump WeakAuras.GetMHTenchInfo() , it returns unknown about enchanted name.
This issue caused by the factor which one chinese charactor occupies two bytes.
WeakAuras Version
3.6.1-2-gef69528
World of Warcraft Flavor
The Burning Crusade
Tested with only WeakAuras
- Yes
- No
Lua Error
No response
Reproduction Steps
Last Good Version
No response
Screenshots
Export String
No response
i try fix this original code by Aura Frames1
Libs\LibAura-1.0\WeaponEnchantments.lua#L58-L85
local patterns = {}
local gsubPatterns = "([^|]+)[|][4]([^:]+):([^;]+);(.*)"
local function SetupWeaponEnchantPatterns()
local temp = {
ITEM_ENCHANT_TIME_LEFT_HOURS, ITEM_ENCHANT_TIME_LEFT_MIN,
ITEM_ENCHANT_TIME_LEFT_SEC
}
for i, v in pairs(temp) do
local raw_i = (i * 2)
patterns[raw_i - 1], patterns[raw_i] =
v:gsub(gsubPatterns, "%1%2%4")
if patterns[raw_i] ~= 0 then
patterns[raw_i] = v:gsub(gsubPatterns, "%1%3%4")
else
patterns[raw_i] = nil
end
end
for i = 1, (#temp) * 2 do
local temp
if patterns[i] then
patterns[i] = patterns[i]:gsub("%((.+)%)", "%%(%1%%)"):gsub(
"%%s", "(.+)"):gsub("%%d", "%%d+")
end
end
end
SetupWeaponEnchantPatterns()
local function GetWeaponEnchantText(text)
local _, enchantText
for i, v in pairs(patterns) do
_, _, enchantText = text:find(v)
if enchantText then return enchantText end
end
end
i try fix this original code by Aura Frames1
Libs\LibAura-1.0\WeaponEnchantments.lua#L58-L85local patterns = {} local gsubPatterns = "([^|]+)[|][4]([^:]+):([^;]+);(.*)" local function SetupWeaponEnchantPatterns() local temp = { ITEM_ENCHANT_TIME_LEFT_HOURS, ITEM_ENCHANT_TIME_LEFT_MIN, ITEM_ENCHANT_TIME_LEFT_SEC } for i, v in pairs(temp) do local raw_i = (i * 2) patterns[raw_i - 1], patterns[raw_i] = v:gsub(gsubPatterns, "%1%2%4") if patterns[raw_i] ~= 0 then patterns[raw_i] = v:gsub(gsubPatterns, "%1%3%4") else patterns[raw_i] = nil end end for i = 1, (#temp) * 2 do local temp if patterns[i] then patterns[i] = patterns[i]:gsub("%((.+)%)", "%%(%1%%)"):gsub( "%%s", "(.+)"):gsub("%%d", "%%d+") end end end SetupWeaponEnchantPatterns() local function GetWeaponEnchantText(text) local _, enchantText for i, v in pairs(patterns) do _, _, enchantText = text:find(v) if enchantText then return enchantText end end end
It works.
@q513902026 that addon is under a ARR license. Please do not suggest stealing code from a addon.