Forum

> > CS2D > Scripts > Russian letters are not displayed normally.
Forums overviewCS2D overview Scripts overviewLog in to reply

English Russian letters are not displayed normally.

9 replies
To the start Previous 1 Next To the start

old Russian letters are not displayed normally.

_Lima_
User Off Offline

Quote
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:
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:
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:

old Re: Russian letters are not displayed normally.

MikuAuahDark
User Off Offline

Quote
As me and the OP discussed in Discord, this quite puzzle me up.

Printing each byte as hex result using code below
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
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.

old Re: Russian letters are not displayed normally.

SQ
Moderator Off Offline

Quote
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.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview