WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Chinese LOCALE and string.sub (https://www.wowinterface.com/forums/showthread.php?t=59427)

gmarco 01-02-23 12:16 PM

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

Dridzt 01-02-23 03:46 PM

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

gmarco 01-03-23 11:48 PM

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.


All times are GMT -6. The time now is 08:56 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI