Forum

> > CS2D > Scripts > Convert utf8 encoding to string
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Convert utf8 encoding to string

Keine Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Convert utf8 encoding to string

ATRI
User Off Offline

Zitieren
This function is for lua hook sayutf8:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
local function utf8_from(t)
	local bytearr = {}
	for _, v in ipairs(t) do
		local utf8byte = v < 0 and (0xff + v + 1) or v
		table.insert(bytearr, string.char(utf8byte))
	end
	return table.concat(bytearr)
end

local function utf8_expend(str) -- Put message
	local t = {}
	for num in str:gmatch('[^x]+') do
		table.insert(t, tonumber(num, 16))
	end
	return utf8_from(t)
end
For example:
1
2
3
print(utf8_expend('x61x7A')) --> 'az'
print(utf8_expend('xE4xBDxA0xE5xA5xBD')) --> '你好'
print(utf8_expend('xD0x9FxD1x80xD0xB8xD0xB2xD0xB5xD1x82')) --> 'Привет'
Sorry, my English is poor
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht