We convert the text into hexadecimal form with the specified delimiter.
1 2 3 4 5 6 7 8 |
var source, dlmtr, res: string; begin source:= 'text'; dlmtr:= '-'; res:= strToHex(source, dlmtr); ShowMessage(res); end; |
Options
source - text
dlmtr - a character that will separate hexadecimal digits (or an empty string if not needed)
Result
A string representing text in hexadecimal (74-65-78-74)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
function strToHex(source, dlmtr: string): string; var i:integer; c:Char; s:string; begin s := ''; for i:= 1 to Length(source) do begin c := source[i]; s := s + IntToHex(Integer(c),2) + dlmtr; end; if dlmtr <> '' then s:= Copy(s, 1, Length(s)-1); result:= s; end; |