Board index » delphi » Convert a String to HEX
Geir Andersen
![]() Delphi Developer |
Sat, 16 Apr 2005 17:26:19 GMT
|
Geir Andersen
![]() Delphi Developer |
Sat, 16 Apr 2005 17:26:19 GMT
Convert a String to HEX
Hi.
I am searching for some code to convert a string to hex. This is what I want: string:= 'Geir'; Can anyone help me with some code to do this?? Thanks in advance. |
Joerg Brueh
![]() Delphi Developer |
Sat, 16 Apr 2005 17:47:56 GMT
Re:Convert a String to HEXHi! QuoteGeir Andersen wrote: 1) Split the string into characters. 2) Convert each individual character into an integer (using the "ord()" function). 3) Write each integer in hexadecimal coding. If your compiler does not offer a notation for step 3, HTH, -- |
Geir Anderse
![]() Delphi Developer |
Sat, 16 Apr 2005 18:47:53 GMT
Re:Convert a String to HEXThanks for the quick answer. I came up with the following: Function Byte2Hex(numb : Byte): String; Const begin procedure conv2val(s : string); procedure hex; The Byte2Hex function I found on the Internet. This works like a charm. Geir "Joerg Bruehe" <jo...@sql.de> skrev i melding Quote> Hi! |
Timo Sal
![]() Delphi Developer |
Sat, 16 Apr 2005 19:24:30 GMT
Re:Convert a String to HEXQuoteGeir Andersen <disk...@nospam.online.no> wrote: 165966 Jan 8 2000 ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip All the best, Timo -- |
CBFalcone
![]() Delphi Developer |
Sat, 16 Apr 2005 19:59:09 GMT
Re:Convert a String to HEXQuoteTimo Salmi wrote: dialect of Pascal, and thus not portable to standards conforming systems. An (untested) conforming version could be: PROCEDURE wrt2hex(VAR f : text; c : char) TYPE VAR BEGIN and you can move the hexindex type and hexchars array outside the -- |
Timo Sal
![]() Delphi Developer |
Sat, 16 Apr 2005 20:43:18 GMT
Re:Convert a String to HEXQuoteCBFalconer <cbfalco...@worldnet.att.net> wrote: just has to formulate for the syntax discrepancies (just as you kindly did). All the best, Timo -- |
Joerg Brueh
![]() Delphi Developer |
Sat, 16 Apr 2005 22:26:33 GMT
Re:Convert a String to HEXHi Geir! QuoteGeir Andersen wrote: Quote> [...] within "conv2val"), and issue a 'writeln'. HTH, -- |
Femme Verbee
![]() Delphi Developer |
Mon, 18 Apr 2005 01:46:03 GMT
Re:Convert a String to HEX"Joerg Bruehe" <jo...@sql.de> schreef in bericht Quote> Hi Geir! Uses crt; |
CBFalcone
![]() Delphi Developer |
Mon, 18 Apr 2005 03:30:29 GMT
Re:Convert a String to HEXQuoteGeir Andersen wrote: very simple: write(f, stringvar : 15); will write the first 15 chars of the string variable only. It DO NOT TOPPOST. -- |