• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3147
  • Last Modified:

Hex to char convert question

Hi all, win2k and delphi 6 here.

    I have a small process that receive a char, i convert it to a hex value, after that i have a convert table which tells me the new hex value. but after i'm stuck at converting back my hex value to a char. any help would be welcome.

just an exemple of where i'm stuck.

function SwapHexValue(mychar : char):char;
var
  ls_string :  string;
begin
  ls_string := inttohex(ord(mychar ),2);
  ls_string := Swap(ls_string);
  result := ???????????//something like result := hextochar(ls_string);
end;

Chad
0
Chadak
Asked:
Chadak
  • 3
1 Solution
 
andrewjbCommented:
Use StrToInt, with a prefix of '0x' - and it automatically oes hex conversion

i.e.

result := StrToInt( '0x' + ls_string );
0
 
GloomyFriarCommented:
IntToStr('$' + ls_string );
0
 
GloomyFriarCommented:
char(StrToInt('$' + ls_string ));
0
 
GloomyFriarCommented:
First post was done by mistake, sorry.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now