Jump to content

Cum Sa Tranform Caracterele Intr-un Cod Binar ?


Recommended Posts

Posted

Inserati codul de mai jos intr-o pagina, php, apoi deschideti-o. (pentru a se deschide pe localhost va trebuie xampp instalat)


<?
// Transformare unui string in cod binar

$Text = "";
$Cod = "w";
$byte = "8";
if (isset($_POST['text'])) {
$nr = strlen($_POST['text']);
for($z=0;$z<$nr;++$z) {
 echo "<font face='tahoma'>".$_POST['text'][$z]." =   "."<b>".CriptChar(ord($_POST['text'][$z]))."</b></font></br>";
}
}
function CriptChar($LiteraASC)   {
       global $byte,$Cod;
       $baza = "128";
       $AscRes = "";
       for ($x=0;$x<$byte;++$x) {
        if ( $LiteraASC >= $baza ) {

         $LiteraASC = $LiteraASC - $baza;
         $AscRes = $AscRes."1";
         }else{
         $AscRes = $AscRes."0";
         }

        $baza = $baza / 2;

       }
       return $AscRes;

}
?>
<form method="post" >
<textarea name="text"></textarea>
<input type="submit" value="Conversie" >

</form>
[/code]

Te-ai inregistrat? Ne-ar placea sa te prezinti.

Cum pot sustine forumul?
Cumpara de la eMag folosind acest link.
--------------------
oG2BN9d.gifse1WdXd.gifQG6MtmI.gifRHYjDzD.gifG5p1wui.gif

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.