4 - Support For Russian Char and Guild Names
What is the enhancement in mind? How should it look and feel?
This is short patch to support Russian Guild and Character names.
Please provide any additional information below.
The main problem with Russian symbols in WAR is incorrect UCS2 to UTF8 implementation for the Russian charset - WStringToString funciton is basically broken for Russian. As well, WarDB seems to accept only UTF8 encoding, so Windows 1251 encoding used for "string" type strings also should be converted into UTF8.
There is pretty simple fix for Curse Profiler to workaround the problem. I provide the code below. After the fix applied to Curse Profiler, WarDB seems to accept and show the data properly (http://www.wardb.com/guild.aspx?id=37608).
Still, there are couple of problems (I think it's on WarDB side):
- My Character is not associated with the Guild (though, it's on Guild Roster) - http://www.wardb.com/profile.aspx?id=642661
- Subsequent updates don't seem to update wardb guild info (but the Character info is updated).
These problems are probably related to WarDB code which handles Guild and Character names when they arrive as valid UTF8.
Please feel free to contact me: maxmpz at gmail dot com or via Skype chat: maxmpz
Fix code below:
==============================================
-- Converts "string" type chars from win1251 to utf8
local function char_win1251_to_utf8(char)
if char >=192 and char <=239 then
return string.char(208) .. string.char(char - 48)
end
if char >=240 and char <=255 then
return string.char(209) .. string.char(char - 112)
end
if char == 0xa8 then
return string.char(208) .. string.char(149)
end
if char == 0xb8 then
return string.char(208) .. string.char(181)
end
if char == 0xda then
return string.char(208) .. string.char(172)
end
if char == 0xdc then
return string.char(208) .. string.char(170)
end
if char == 0xfa then
return string.char(208) .. string.char(140)
end
if char == 0xfc then
return string.char(208) .. string.char(138)
end
return string.char(char)
end
-- Converts "string" type strings from win1251 to utf8
local function win1251_to_utf8(str)
utf8 = ""
for index = 1, string.len(str) do
utf8 = utf8 .. char_win1251_to_utf8(string.byte(str, index))
end
return utf8
end
-- Converts "wstring" type chars from UCS2 to win1251
local function toruchar( wchar )
if iswruchar( wchar ) == false then
while wchar >= 0x0100 do
wchar = wchar - 0x0100
end
return wchar
elseif wchar == 0x0451 then
return 0xB8
elseif wchar == 0x0401 then
return 0xA8
else
return ( wchar - 0x0350 )
end
end
-- Converts "wstring" type strings from UCS2 to win1251
local function RuWStringToString ( wstr, ... )
if type( wstr ) == "wstring" then
local ruStr = ""
for index = 1, wstring.len(wstr) do
ruStr = ruStr .. string.char(toruchar( wstring.byte(wstr, index) ) )
end
return ruStr
end
return WStringToString( wstr, ... )
end
-- Patched Curse Profiler function
function CurseProfiler.untilfalse(str)
if(str==nil) then
return ""
elseif type(str)=="string" then
return win1251_to_utf8(str)
elseif type(str) == "wstring" then
return win1251_to_utf8(RuWStringToString(str))
else
return tostring(str)
end
end
| User | When | Change |
|---|---|---|
| Petrowi4 | Tue, 17 Mar 2009 12:59:14 | Create |
- 2 comments
- 2 comments
Facts
- Last updated on
- 01 May 2009
- Reported on
- 17 Mar 2009
- Status
- New - Issue has not had initial review yet.
- Type
- Enhancement - A change which is intended to better the project in some way
- Priority
- Medium - Normal priority.
- #2
Petrowi4 Tue, 24 Mar 2009 07:04:07This is the info for Curse/WarDB people, patching Curse Profiler on client side won't work (Curse Client won't upload the data as it detects "wrong" addong). Anyway, wardb seems to be broken on updates for about a week...
- #1
pr1me Mon, 23 Mar 2009 17:17:58Thank you for ur work. Can you give more instructions how to apply a fix?