I'm using tags for my oUF layout that abbreviate long names.
Code:
local oldName = UnitName(unit)
local newName = (string.len(oldName) > 14) and string.gsub(oldName, "%s?(.[\128-\191]*)%S+%s", "%1. ") or oldName
if not UnitIsPlayer(unit) then
return utf8sub(newName, 14, false)
else
return oldName
end
Everything works fine, but on level up the following error can occur. It only seems to happen when the unit name contains letters like "Æ", "Ø" and the like.
(Line 47 is highlighted red, above.)
Code:
Message: Interface\AddOns\oUF_Slim\Slim_Tags.lua:47: bad argument #1 to 'len' (string expected, got nil)
Time: 11/18/10 18:43:03
Count: 1
Stack: [C]: in function `len'
Interface\AddOns\oUF_Slim\Slim_Tags.lua:47: in function `func'
Interface\AddOns\oUF\elements\tags.lua:595: in function `UpdateTag'
Interface\AddOns\oUF\elements\tags.lua:375: in function <Interface\AddOns\oUF\elements\tags.lua:370>
Locals: (*temporary) = nil
(*temporary) = "string expected, got nil"
What I do not get is why it happens on level up. Normally, you can switch through units with no matter what characters and the name always abbreviates/updates correctly.
Any idea how to fix it or maybe a workaround?