Ultima modifica da un moderatore:
Salve gente,
vi mostro questa funzione utile alla conversione/codifica dei caratteri UTF-8 in unicode/ASCII.
Guida all'utilizzo:
Copiare il codice riportato sopra in un file separato dal questlib.lua (per comodità..) ed includerlo col comando "dofile" all'inizio del questlib.lua, oppure, copiare direttamente il codice all'interno del questlib.lua nelle prime righe.
Riavviate oppure fatte un bel "reload q" in game e aprire una delle vostre quest con accenti in game. (Non è più necessario il sayf.)
Godetevi le vostre quest accentate.
Per chi non ha capito di cosa sto parlando, guardi quest'immagine:
vi mostro questa funzione utile alla conversione/codifica dei caratteri UTF-8 in unicode/ASCII.
Codice:
--[[
Devilkyroth's small library for encode utf8 characters to ASCII/unicode.
]]--
_say = say
_chat = chat
_syschat = syschat
_cmdchat = cmdchat
_notice = notice
_notice_all = notice_all
say = function(text)
return _say(utf8_decode(text))
end
chat = function(text)
return _chat(utf8_decode(text))
end
syschat = function(text)
return _syschat(utf8_decode(text))
end
cmdchat = function(text)
return _cmdchat(utf8_decode(text))
end
notice = function(text)
return _notice(utf8_decode(text))
end
notice_all = function(text)
return _notice_all(utf8_decode(text))
end
function utf8_decode(utf8)
local unicode = ""
local mod = math.mod
local pos = 1
while pos < string.len(utf8)+1 do
local v = 1
local c = string.byte(utf8,pos)
local n = 0
if c < 128 then
v = c
elseif c < 192 then
v = c
elseif c < 224 then
v = mod(c, 32) n = 2
elseif c < 240 then
v = mod(c, 16) n = 3
elseif c < 248 then
v = mod(c, 8) n = 4
elseif c < 252 then
v = mod(c, 4) n = 5
elseif c < 254 then
v = mod(c, 2) n = 6
else
v = c
end
for i = 2, n do
pos = pos + 1
c = string.byte(utf8,pos)
v = v * 64 + mod(c, 64)
end
pos = pos + 1
if v < 255 then
unicode = unicode..string.char(v)
end
end
return unicode
end
Guida all'utilizzo:
Copiare il codice riportato sopra in un file separato dal questlib.lua (per comodità..) ed includerlo col comando "dofile" all'inizio del questlib.lua, oppure, copiare direttamente il codice all'interno del questlib.lua nelle prime righe.
Riavviate oppure fatte un bel "reload q" in game e aprire una delle vostre quest con accenti in game. (Non è più necessario il sayf.)
Godetevi le vostre quest accentate.
Per chi non ha capito di cosa sto parlando, guardi quest'immagine: