local function AnsiToUtf8(x) local l,i,s = #x,0,"" if l>0 then while i<l do i=i+1 local f,a,b = 0,0,string.byte(x,i) if b<=127 then f=1 elseif b==168 then a,b,f=208,129,1 elseif b==184 then a,b,f=209,145,1 elseif b>=192 and b<=239 then a,b,f=208,b-48,1 elseif b>=240 and b<=255 then a,b,f=209,b-112,1 end if a~=0 then s=s..string.char(a) end if f==1 then s=s..string.char(b) end end end return s end local function Utf8ToAnsi(x) local l,i,s = #x,0,"" if l>0 then while i<l do i=i+1 local f,b = 0,string.byte(x,i) if b<=127 then f=1 elseif i~=l then if b==208 then i=i+1 b=string.byte(x,i) if b==129 then b,f=168,1 elseif b>=144 and b<=191 then b,f=b+48,1 end elseif b==209 then i=i+1 b=string.byte(x,i) if b==145 then b,f=184,1 elseif b>=128 and b<=143 then b,f=b+112,1 end elseif b==194 then i=i+1 b=string.byte(x,i) if b==160 then b,f=32,1 end elseif b==226 then i=i+1 b=string.byte(x,i) if b==128 then i=i+1 b=string.byte(x,i) if b==147 then b,f=45,1 end end end end if f==1 then s=s..string.char(b) end end end return s end |