2 Bytes Chars Problem

This is pretty serious problem. Especially with markup or char replace/trimming.

Markup’s Wrapping is not working properly with 2 byte chars.
When you’re doing some string replace/trimming with 2 Bytes char, You’ll see some ? chars or chars on the result. Just like cutting a cake in half.

I just found string like “#”, “○”, “━”, “ア”, “청” takes 3 bytes.

Use this to get the proper length of characters like that: http://pastebin.com/CKym08U0

I ran this code:
[lua]local str = “Unicode 아 스 키 ア ア” surface.SetFont"ChatFont" for i=1, string.len(str) do local x, y = surface.GetTextSize(str*) LocalPlayer():ChatPrint(“string:” … str* … " size:" … x … " byte:" … string.byte(str*)) end[/lua]

and I got this


string:U size:11 byte:85
string:n size:9 byte:110
string:i size:4 byte:105
string:c size:9 byte:99
string:o size:9 byte:111
string:d size:9 byte:100
string:e size:9 byte:101
string:  size:6 byte:32
string:� size:14 byte:236
string:� size:14 byte:149
string:� size:14 byte:132
string:  size:6 byte:32
string:� size:14 byte:236
string:� size:14 byte:138
string:� size:14 byte:164
string:  size:6 byte:32
string:� size:14 byte:237
string:� size:14 byte:130
string:� size:14 byte:164
string:  size:6 byte:32
string:� size:14 byte:227
string:� size:14 byte:130
string:� size:14 byte:162
string:  size:6 byte:32
string:� size:14 byte:227
string:� size:14 byte:130
string:� size:14 byte:162


I think I just found why Garrysmod’s markup is just fucked up horribly.

[editline]15th February 2014[/editline]

OH GOD THANKS CHEWGUM!