2
This file is part of the Free Component Library (FCL)
3
Copyright (c) 1999-2000 by Michael Van Canneyt and Florian Klaempfl
5
See the file COPYING.FPC, included in this distribution,
6
for details about the copyright.
8
This program is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
**********************************************************************}
14
procedure BinToHex(BinValue, HexValue: PChar; BinBufSize: Integer);
16
HexDigits='0123456789ABCDEF';
20
for i:=0 to binbufsize-1 do
22
HexValue[0]:=hexdigits[1+((ord(binvalue^) shr 4))];
23
HexValue[1]:=hexdigits[1+((ord(binvalue^) and 15))];
30
function HexToBin(HexValue, BinValue: PChar; BinBufSize: Integer): Integer;
31
// more complex, have to accept more than bintohex
35
var i,j,h,l : integer;
41
if hexvalue^ IN ['A'..'F','a'..'f'] then
42
h:=((ord(hexvalue^)+9) and 15)
43
else if hexvalue^ IN ['0'..'9'] then
44
h:=((ord(hexvalue^)) and 15)
48
if hexvalue^ IN ['A'..'F','a'..'f'] then
49
l:=(ord(hexvalue^)+9) and 15
50
else if hexvalue^ IN ['0'..'9'] then
51
l:=(ord(hexvalue^)) and 15