English Russian letters are not displayed normally.

9 replies
Goto Page
To the start Previous 1 Next To the start
Up
_Lima_
User
Offline Off
I need Russian letters to be displayed normally, I want to make local, global, faction(team), walkie-talkie chat.
Various chats. This is needed for my rp server. The only problem is that Russian letters are displayed incorrectly.

I tried to make this script, but it doesn't work:
Code:
1
2
3
4
5
addhook("say","say_test")
function say_test(id, txt)
msg("UTF-8:"..txt.."")
return 1
end

The word "Привет" turns into: @825B.

This one doesn't work either:
Code:
1
2
3
4
5
addhook("say", "say_test")
function say_test(id, txt)
  msg("UTF-8:"..txt:gsub(".", function(t) return string.format("x%02X", t:byte()) end))
  return 1
end


Maybe need to use this method: https://mothereff.in/utf-8#Привет
\xD0\x9F\xD1\x80\xD0\xB8\xD0\xB2\xD0\xB5\xD1\x82 = Привет
I don't know how to do that. Need help. @user MikuAuahDark:
S.T.A.L.K.E.R. RP - https://discord.gg/wQUEKSB
24.05.21 03:43:22 pm
Up
MikuAuahDark
User
Offline Off
As me and the OP discussed in Discord, this quite puzzle me up.

Printing each byte as hex result using code below
Code:
1
2
3
4
5
addhook("say", "say_test")
function say_test(id, txt)
     msg(txt:gsub(".", function(t) return string.format("x%02X", t:byte()) end))
     return 1
end

result in this being shown (top is "Привет", bottom is "Hello")
IMG:https://cdn.discordapp.com/attachments/641771891421347890/846374953859285003/1.PNG


Further by writing reverse function for it
Code:
1
2
3
function r(t)
     return t:gsub("x(%x%x)", function(x) return string.char(tonumber(x, 16)) end)
end

confirms that "Привет" gets transformed to "@825B" at cs2d lua hook say.
IMG:https://cdn.discordapp.com/attachments/641771891421347890/846375240337981450/unknown.png


I'd also like to know the solution to this problem.
file cs2d LuaJIT for Dedicated Server (13) JIT POWER! | Know your Lua errors! | Part of LÖVE development team since 11.3
25.05.21 01:31:04 pm
Up
StirlizZ-Fapicon
Super User
Offline Off
Problem in the code itself, only SQ can manage to fix that, he already fixed that issue for main chat. Ask him for more if you want so.
CS2d for ANDROID Discord server is here: https://discord.gg/ww59nvf
25.05.21 01:52:22 pm
Up
SQ
Moderator
Offline Off
Have you tried this extension?

file cs2d [EngiN33R] UTF-8 Wrapper Library (11)
25.05.21 02:36:59 pm
Up
_Lima_
User
Offline Off
user SQ has written:
Have you tried this extension?

file cs2d [EngiN33R] UTF-8 Wrapper Library (11)
Yes, it doesn't work. I would not even use this script, because of it the server lags.
S.T.A.L.K.E.R. RP - https://discord.gg/wQUEKSB
25.05.21 04:32:04 pm
Up
MikuAuahDark
User
Offline Off
user SQ has written:
Have you tried this extension?

file cs2d [EngiN33R] UTF-8 Wrapper Library (11)


The problem is not that (if it works then my one-liner string.gsub equivalent should display correct text), but it seems cs2d lua hook say doesn't pass UTF-8-encoded Russian text.
file cs2d LuaJIT for Dedicated Server (13) JIT POWER! | Know your Lua errors! | Part of LÖVE development team since 11.3
25.05.21 05:06:32 pm
Up
SQ
Moderator
Offline Off
Oh that, I was working on this. I don't remember if I finished implementing solution.

Optimal way was to add "say_utf8" hook that would pass encoded text.
Original say hook provides byte characters only.
25.05.21 07:54:43 pm
Up
StirlizZ-Fapicon
Super User
Offline Off
@user SQ: as far as i remember that, problem was with counting bytes when parsing texts or something. You fixed that for chat itself when we talked in a discord
CS2d for ANDROID Discord server is here: https://discord.gg/ww59nvf
31.05.21 05:20:33 pm
Up
_Lima_
User
Offline Off
Will there be any update to correct the Russian letters in the custom chat? It is very important us.
S.T.A.L.K.E.R. RP - https://discord.gg/wQUEKSB
20.06.21 08:44:31 pm
Up
2Gen
User
Offline Off
@user _Lima_: I hope this one will help file cs2d 2Gen's "Simple UTF-8" (4) Especially for you.
To the start Previous 1 Next To the start