Codage

Texte ŕ coder




Code source

<HTML>
<HEAD>
<TITLE>ascii</TITLE>
<style type="text/css">
a {text-decoration:none}
a:hover {background-color:teal;color:yellow}
INPUT {Color: #2207B8;Background-Color: #ff8000;font-weight:bold;}
TEXTAREA{Color: #2207B8;Background-Color: #ff8000;font-weight:bold;}
select{Color: #2207B8;Background-Color: #ff8000;font-weight:bold;}
</style>
</HEAD>
<BODY bgcolor=navy>
<div align=center>
<table width=800 bgcolor=lightgreen><tr><td>
<div align=center>
<H1>Codage</H1>
<FORM NAME="form1" action="ascii1.htm?">
Texte ŕ coder <INPUT TYPE="text" NAME="longueur" SIZE= "80" >
<input type="hidden" name="l" value="1">
<BR>
<font size=4><BR>
<input type="submit" value=" Valider">
<BR>
</FORM>
<HR>
<script language="JavaScript"> <!--
var requete = window.location.search ;
if (requete) {
requete=requete.substring(1) ;
requete = unescape(requete) ;
}
var elem = requete.split('&');
l1= elem[0];
l2 = elem[1];
var fin1 = l1.split('=');
var fin2 = l2.split('=');
Chaine=fin1[1];
code=fin2[1];
var mot=Chaine;
var codes="";
document.write("<font size=3><B><U>Texte ŕ coder:</U>  ")
document.write(mot+"</B><br>");
document.write("<BR><B><U>Codage</U></B><br>");
for (var i=0; i<mot.length; i++) {
document.write("Code ASCII de "+mot.charAt(i)+"="+mot.charCodeAt(i)+"<BR>");
codes=(codes+mot.charCodeAt(i)+",");
}
document.write("<BR><B><U>Codes ŕ transmettre :</U>  </B>");
cdx=codes+"32";
document.write(cdx+"<br>");
document.write("<I>J'ai ajouté le code 32 (barre d'espace) pour marquer la fin du texte.</I><br>");
-->
</script>
<HR>
</td></tr>
</table>
</div>
</BODY>
</HTML>