Forum

> > CS2D > Scripts > Russian letters are not displayed normally.
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Russian letters are not displayed normally.

9 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Russian letters are not displayed normally.

_Lima_
User Off Offline

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

alt Re: Russian letters are not displayed normally.

MikuAuahDark
User Off Offline

Zitieren
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.

alt Re: Russian letters are not displayed normally.

SQ
Moderator Off Offline

Zitieren
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.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht