Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Hex with Delphi

DebianDebian Member Posts: 9
Could anyone tell me how to covert Hex to String ?


  • zibadianzibadian Member Posts: 6,349
    : Could anyone tell me how to covert Hex to String ?
    : Thanks
    Here is an untested function to convert a Hex to integer, then you can use IntToStr.
    function HexToInt(Hex: string): integer;
    Result := 0;
    if Length(Hex) > 8 then
    raise EConvertError.CreateFmt('%s is to large to convert!', [Hex]);
    while Hex <> '' do begin
    if Pos(Hex[1], HexValues) > 0 then
    Result := Result * 16 + Pos(Hex[1], HexValues) - 1
    // Multiply current Result with 16 and add next hex-digit
    raise EConvertError.CreateFmt('%s is not a hex-digit!', [Hex[1]]);
    Delete(Hex, 1, 1); // Remove processed digit
    I hope this is what you meant by converting hex to string.
  • ManningManning Member Posts: 1,621
    : Could anyone tell me how to covert Hex to String ?

    What exactly do you mean by converting hex to string? Since a hexadecimal number may contain the letters A through F, it already is a string.
  • Chris BrownChris Brown USAMember Posts: 4,624 ✭✭

    ___ < /> free video tutorials and ebooks about [ JavaScript PL/SQL Delphi Python MATLAB Visual Basic Objective-C Java Ruby C++ R C# PHP Perl Assembly Swift Scratch Visual Basic .NET Go C Logo COBOL D Apex Alice Bash Fortran SAS ML Scheme ABAP Rust Kotlin Ada LabVIEW VBScript Hack Transact-SQL Julia Lisp Scala FoxPro Clojure Lua Crystal F# Prolog Awk Dart Erlang ] _____

Sign In or Register to comment.