Prat 3.0

538 - AltNames bug with special characters

Hi,

First of all, sorry for my english.
AltNames module has a bug when main name contain special characters.

For example :
My main's name is Neøkiki and my alt is Neokiki.
Public note for Neøkiki is clear and public note for Neokiki is : "Neøkiki's alt"

When I scan guild alts, Neokiki isn't found (because of "ø")

The same thing is happening for a friend (her main is Shéléna ans her alt is Shélé).

Maybe a problem with "formatCharName" function ?

User When Change
NeWoKiKi Jun 28, 2011 at 11:27 UTC Create

You must login to post a comment. Don't have an account? Register to get one!

  • 2 comments
  • Avatar of turbopipp turbopipp Nov 09, 2011 at 11:37 UTC - 0 likes

    I am not sure how it needs to be coded to be able to accept these special characters, but if its any help, here is the ALT + <number> codes for special characters;

    á=160 Á=0193 à=133
    À=0192 â=131
    Â=0194 ä=132
    Ä=0196 å=134
    Å=0197 ª=166
    æ=145
    Æ=146
    ç=135
    Ç=128
    é=130
    É=144 è=138
    È=0200 ê=136
    Ê=0202 ë=137
    Ë=0203
    í=161
    Í=0205 ì=141
    Ì=0204 î=140
    Î=0206 ï=139
    Ï=0207
    ñ=164
    Ñ=165
    ó=162
    Ó=0211 ò=149
    Ò=0210 ô=147
    Ô=0212 ö=148
    Ö=153 º=167
    ú=163
    Ú=0218 ù=151
    Ù=0217 û=150
    Û=0219 Ü=154
    ý=0253
    Ý=0221 ÿ=152
    

    Hope to see an update soon, ty :)

    edit:I think I found the solution online.

    The built-in Lua function string.sub() does not work correctly with the UTF-8 strings that are pervasive in non-US clients for World of Warcraft. For example, run the following code in WoW:

    /run print(string.sub("Gnøppix", 1, 3))
    

    WoW will show Gn?, which is not what we would expect. This is due to ø being a multi-byte UTF character (it's built of two bytes "\195\184". Luckily, the UTF standard is very regular and well-defined. The following function can take a substring of a UTF-8 string:

    print(utf8sub("Gnøppix", 1, 2)) Gn print(utf8sub("Gnøppix", 1, 3)) Gnø print(utf8sub("Gnøppix", 2, 3)) nøp
    

    Note that the first parameter describes an offset in byte, whereas the second parameter describe a count in codepoint. Note also that this function will return an incorrect result if the first parameter does not correspond to a codepoint boundary.

    -- UTF-8 Reference:
    -- 0xxxxxxx - 1 byte UTF-8 codepoint (ASCII character)
    -- 110yyyxx - First byte of a 2 byte UTF-8 codepoint
    -- 1110yyyy - First byte of a 3 byte UTF-8 codepoint
    -- 11110zzz - First byte of a 4 byte UTF-8 codepoint
    -- 10xxxxxx - Inner byte of a multi-byte UTF-8 codepoint
     
    local function chsize(char)
        if not char then
            return 0
        elseif char > 240 then
            return 4
        elseif char > 225 then
            return 3
        elseif char > 192 then
            return 2
        else
            return 1
        end
    end
     
    -- This function can return a substring of a UTF-8 string, properly handling
    -- UTF-8 codepoints.  Rather than taking a start index and optionally an end
    -- index, it takes the string, the starting character, and the number of
    -- characters to select from the string.
     
    local function utf8sub(str, startChar, numChars)
      local startIndex = 1
      while startChar > 1 do
          local char = string.byte(str, startIndex)
          startIndex = startIndex + chsize(char)
          startChar = startChar - 1
      end
     
      local currentIndex = startIndex
     
      while numChars > 0 and currentIndex <= #str do
        local char = string.byte(str, currentIndex)
        currentIndex = currentIndex + chsize(char)
        numChars = numChars -1
      end
      return str:sub(startIndex, currentIndex - 1)
    end
    

    Source: http://wowprogramming.com/snippets/UTF-8_aware_stringsub_7

    Here is another update; The databases contain the correct main and alt names, and even when I click "List all" in the AltNames menu, it shows the correct mains -> alts printed. But the mainname just doesn't show in the chat box when an alt writes something in gchat/whisper/whatever.

    Last edited Nov 09, 2011 by turbopipp
  • Avatar of user_623448 user_623448 Nov 07, 2011 at 20:40 UTC - 0 likes

    I have also noticed this problem, in my guild its mostly mainnames with áàéèæøå, and also some officers write "mainname´s alt" instead of "mainname's alt", they use " ´ " instead of " ' ", its a small thing, but I still think both should be valid formats. :)

    I have been waiting many months for an update with the altnames module, and I would greatly appretiate it if it got some attention soon. :)

    So to clarify the guildnote problem with special chars; its when the mainname contains special characters. The guildnote on the alts are written perfectly, but prat / altnames does not find the main of that alt, it seems.

  • 2 comments

Facts

Last updated
Mar 30, 2012
Reported
Jun 28, 2011
Status
New - Issue has not had initial review yet.
Type
Defect - A shortcoming, fault, or imperfection
Priority
Medium - Normal priority.
Votes
2
Component
Specific Module

Reported by

Possible assignees