Les Snippets

Connexion

Convertion toutes données vers chaine representation binaire

Niveau requis pour utiliser/comprendre cette source : 2 ( Initié )
Créé le 04/03/2007 15:34:38 et initié par f0xi [Liste]
Date de mise à jour : 30/03/2007 09:54:31
Vue : 9189
Catégorie(s) : Trucs & Astuces, Algorithme, Chaîne de caractères
Langages dispo pour ce code :
- Delphi 5



Langage : Delphi 5
Date ajout : 04/03/2007
Posté par f0xi [Liste]
DateMAJ : 30/03/2007
{ ToBinStr
   
   convertion d'un buffer vers representation binaire
   params : 
      Buffer [i] constante non typée
      BufferSize [i] taille du buffer en octets
   returns :
      String, chaine de caractere representant buffer en binaire.
}
function ToBinStr(const Buffer; const BufferSize : integer) : string;
var
  pB : ^byte;
  pR : PChar;
  N  : integer;
const
  BC : array[boolean] of char = '01';
begin
  pB := @Buffer;
  inc(pB, BufferSize-1);
  SetLength(result, BufferSize shl 3);
  pR := PChar(Result);
  for N := 0 to BufferSize-1 do
  begin
    pR[0] := BC[ (pB^ and $80) = $80 ];
    pR[1] := BC[ (pB^ and $40) = $40 ];
    pR[2] := BC[ (pB^ and $20) = $20 ];
    pR[3] := BC[ (pB^ and $10) = $10 ];
    pR[4] := BC[ (pB^ and $08) = $08 ];
    pR[5] := BC[ (pB^ and $04) = $04 ];
    pR[6] := BC[ (pB^ and $02) = $02 ];
    pR[7] := BC[ (pB^ and $01) = $01 ];
    dec(pB);
    inc(pR,8);
  end;
end;

Snippets en rapport avec : Convertion, Binaire



Codes sources en rapport avec : Convertion, Binaire

{C / C++ / C++.NET} OBTENIR L'ETAT DES BITS QUI COMPOSENT UN OCTET (CONVERSION XX->BINAIRE)
J'ai regardé très rapidement si la source n'existait pas et je ne l'ai pas trouvé. Je précise que c...

{ASP / ASP.NET} ASP.NET - FONCTION DE PASSAGE D'UN FICHIER BINAIRE VERS UN TABLEAU DE BYTE
Dans le cas d'utilisation de Classe d'objet complexe, certains paramêtres peuvent être des fichiers ...

{C# / C#.NET} SÉRIALISATION (BINAIRE) OBJECT, IMAGE, CLASS ...
C'est une petite classe qui permet de sérialiser un Object, Avec quelques exemples d'utilisation. ...

{C / C++ / C++.NET} FONCTION D'ÉDITION DE FICHIER BIT À BIT [C-MULTIPLATEFORME]
.......................................................................................................

{C / C++ / C++.NET} UN GESTIONNAIRE DU FICHIER
un gestionnaire de fichier qui permet de créer, afficher, et savoir certais details sur un fichier, ...

{Python} TRANSFERT DE FICHIER PAR SOCKET
Voici un script pour transférer un fichier par socket. Le programme fait serveur si on indique aucun...

{JAVA / J2EE} PUISSANCE ENTIERE
c est un tp que je le fait pour faire la comparaison entre 3 méthode pour calculer la puissance enti...

{Visual Basic, VB6, VB.NET, VB 2005} PROFIL BINAIRE D'UN OBJET
Ce qu'on veut : stocker (entrée - sortie) dans 1 variable (1 colonne de 1 ligne de BdD) un ensemble...

{JAVA / J2EE} CODAGE DES BASES EN BINAIRE
SIMPLE TRAVAIL PERMET DE CODER LES NOMBRES DANS DIFFÉRENTES BASES ET AUSSI LE TEXTE(CODAGE, DÉCODAGE...

{Delphi} SIZECONVERTER : UNE MINI LIBRAIRIE DE CONVERSION DE TAILLE
J'avais besoin de convertir des tailles de fichier exprimées en diférentes unités (Ko, Mo, Go...) en...