1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| <%
Response.Charset="ISO-8859-1"
sub echo(s)
response.write s
end sub
function numeric_entify_utf8(utf8_string)
out=""
ns=len(utf8_string)
for nn=0 to ns-1
ch=mid(utf8_string, nn+1, 1)
ii=asc(ch)
if ii<128 then '1 7 0bbbbbbb (127)
out=out&ch
elseif(int(ii/32)=6) then '2 11 110bbbbb 10bbbbbb (2047)
b1=(ii and 31)
nn=nn+1
ch=mid(utf8_string, nn+1, 1)
ii=asc(ch)
b2=(ii and 63)
ii=(b1 * 64) + b2
ent="&#"&ii&";"
out=out&ent
elseif(int(ii/16)=14) then '3 16 1110bbbb 10bbbbbb 10bbbbbb
b1=(ii and 31)
nn=nn+1
ch=mid(utf8_string, nn+1, 1)
ii=asc(ch)
b2=(ii and 63)
nn=nn+1
ch=mid(utf8_string, nn+1, 1)
ii=asc(ch)
b3=(ii and 63)
ii=(((b1 * 64) + b2) * 64) + b3
ent="&#"&ii&";"
out=out&ent
elseif(int(ii/8)=30) then '4 21 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
b1=(ii and 31)
nn=nn+1
ch=mid(utf8_string, nn+1, 1)
ii=asc(ch)
b2=(ii and 63)
nn=nn+1
ch=mid(utf8_string, nn+1, 1)
ii=asc(ch)
b3=(ii and 63)
nn=nn+1
ch=mid(utf8_string, nn+1, 1)
ii=asc(ch)
b4=(ii and 63)
ii=(((((b1 * 64) + b2) * 64) + b3) * 64) + b4
ent="&#"&ii&";"
out=out&ent
end if
next
numeric_entify_utf8=out
end function
if Request.Form("str")<>"" then
chaine = replace(replace(Request("str"), "<", "<"), ">", ">")
else
Set ASPTear = Server.CreateObject("SOFTWING.ASPTear")
chaine = ASPTear.Retrieve(Cstr("http://www.monsite.com/mon_fichier_utf-8.txt"), 2, "", "", "")
Set ASPTear=Nothing
end if
echo numeric_entify_utf8(chaine)
%> |
Partager