UTF-8 lib and support for UTF-8 data in markup lib #943

Merged
merged 2 commits into from Sep 6, 2015

Projects

None yet

6 participants

@willox
Collaborator
willox commented May 13, 2015

This adds a global utf8 library which works similarly to Lua 5.3's utf8 library and uses that in the markup library, allowing for UTF-8 data to be correctly displayed and word-wrapped.

local obj = markup.Parse( [[
<font=ChatFont>With Spaces:</font>
激光, 這兩個字是甚麼意思

私は日 本人を見つけ ることができ ません

Я не могу найти русский

Hello, World! I am really not artistic.


<font=Chatfont>No Spaces:</font>
激光,這兩個字是甚麼意思

私は日本人を見つけることができません

Янемогунайтирусский

Hello,World!Iamreallynotartistic.

</font>]], 96 )

hook.Add( "HUDPaint", "", function()

    obj:Draw( 100, 100 )

end )

Should solve Facepunch/garrysmod-issues#1420.

@willox
Collaborator
willox commented May 13, 2015

I should also mention that this also adds a function not existent in Lua 5.3: utf8.force. It simply replaces any invalid UTF-8 sequence with U+FFFD (the Unicode replacement character).

This is a lazy way for users to ensure a string contains only valid UTF-8 data.

@Donkie
Contributor
Donkie commented May 17, 2015

👍 x 💯

@0tt
Contributor
0tt commented Aug 17, 2015

👍

@mcd1992
Contributor
mcd1992 commented Aug 18, 2015

👍

@robotboy655 robotboy655 merged commit d80cc35 into garrynewman:master Sep 6, 2015
@robotboy655 robotboy655 referenced this pull request in Facepunch/garrysmod-issues Sep 6, 2015
Closed

markup.Parse gives weird word wrap when text has unicode symbols. #1420

@willox willox deleted the unknown repository branch Sep 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment