Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Ayuda String to Array of Bytes (https://www.clubdelphi.com/foros/showthread.php?t=64719)

vicoxl16 15-04-2009 23:45:20

Ayuda String to Array of Bytes
 
Hola Amigos Soy Nuevo en Delphi y me encontre con un problema del como convertir una cadena a Array of byte y

convertir un array of bytes a cadena


REGISTRO:array[0..191] of byte=(
$FC,$1E,$03,$00,$00,$0C,$01,$0E,$00,$42,$75,$66,$66,$65,$72,$4F,$76,$65,$72,
$66,$6C,$6F,$77,$0C,$D4,$00,$7F,$00,$00,$15,$79,$48,$DE,$10,$92,$14,$69,$FE,
$CE,$10,$1A,$0F,$00,$00,$00,$00,$00,$00,$D3,$6D,$59,$0B,$ED,$35,$1B,$0A,$5A,
$0B,$1D,$2E,$91,$44,$DE,$10,$92,$14,$61,$4C,$DE,$10,$92,$14,$0A,$0E,$CF,$10,
$02,$13,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,
$00,$00);


Bueno, SI Alguien Me puede ayudar le estare agradecido

hach 16-04-2009 01:00:47

String to array of bytes y vi cerveza
 
Hola,
si te entendi bien estas funciones te van a servir:

Código Delphi [-]
function StringToHexa(texto:String; var dato:array of byte):Boolean;
var i : longint;
begin
  Result := FALSE;
  if trim(texto) = '' then exit;
  if Length(texto) = 1 then texto := '0' +  texto;

  For i := 1 To Length(texto) div 2 do
    dato[i - 1] := strtoint('$' + MidStr(texto, (i * 2) - 1, 2));
  Result := True;
end;

 
function HexaToString(dato: array of byte): string;
var i: longint;
begin
 Result := '';
 for i := 0 To high(dato) do
  Result := Result  + IntToHex(dato[i], 2);
end;


Saludos

Pablo

vicoxl16 19-04-2009 22:27:47

RE: Tanks
 
Muchas Grasias Ami la Funcionde HexaToString me va de Lujo


solo una consulta en la funcion StringToHexa como ago para su llamado

Informacion:array[0..191] of byte

Te lo Agradeceria Amigo

hach 20-04-2009 02:04:04

uso StringToHexa
 
Código Delphi [-]
Informacion:array[0..191] of byte;
strHexa: String;
 
strHexa:=´0102A1FF´;
 
StringToHexa(strHexa, Informacion);


La franja horaria es GMT +2. Ahora son las 10:09:40.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi