Thread Tools Display Modes
01-02-23, 12:16 PM   #1
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
Chinese LOCALE and string.sub

Hi all,

someone knows why this is happening ?



Is Lua able to parse the Chinese language string or this is not a conventional string so the string.sub is not the right thing to do !?

Thanks for any input and Happy New Year to everyone

P.s.
We was discussing here:
https://www.wowinterface.com/downloa....html#comments
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.

Last edited by gmarco : 01-02-23 at 12:19 PM.
  Reply With Quote
01-02-23, 03:46 PM   #2
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
string library assumes single byte characters, Chinese are multibyte.

You need a library like UTF8 in order to do some of these operations.
https://www.curseforge.com/wow/addons/utf8
  Reply With Quote
01-03-23, 11:48 PM   #3
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
Hi Dridzt,

thanks so much for your reply and suggestion.

I imagined it was related to a multibyte problem but didnt know how to solve
Now I know it could be done with this library.

But because I am not so sure that the first char I get from a multibyte locale string means what I want I have adopted a mixed approach solution

For single byte locale string I use the normal string.sub , for multiibyte I prefer to provide (if any) a preset string in localization.lua.

Lua Code:
  1. fort1 = string.sub(C_ChallengeMode.GetAffixInfo(10),1,1)
  2. tyra1 = string.sub(C_ChallengeMode.GetAffixInfo(9),1,1)
  3. if GetLocale() == "zhTW" then
  4.    fort1 = L["F"]
  5.    tyra1 = L["T"]
  6. end
  7. ... bla bla

Btw thanks so much for your kind reply.
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Chinese LOCALE and string.sub


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