Jump to content
smus

Hex to ASCII

Recommended Posts

Couldn't find the information how on how to convert the hex values into ascii ('31' > '1', '32' > '2' etc.). Could anyone remind me which method/function I should use?

Share this post


Link to post
Share on other sites

I'm assuming you're talking about VBScript and not Javascript.  If you're talking about getting an ASCII character from an 8-bit number, you use Chr for that.  I don't see a function to convert a hex number to int (I don't think VBScript recognizes hex numbers at all), so you would probably have to just write a function to take a string of hex digits and convert to integer.

Share this post


Link to post
Share on other sites

Yes, exactly, VBScript. I've found the way to perform the opposite action (ascii into hex):

dim x

x = 1

response.write hex(asc(x))

//31

but have no idea about the backward conversion.

Edited by smus

Share this post


Link to post
Share on other sites

It's pretty straight-forward, there should be plenty examples online.

Share this post


Link to post
Share on other sites
On ‎1‎/‎28‎/‎2019 at 11:53 PM, justsomeguy said:

It's pretty straight-forward, there should be plenty examples online.

It is, but to be honest, I couldn't find the solution. Unfortunately, classic ASP is not really popular nowadays.

Share this post


Link to post
Share on other sites

If you're looking for something you can copy and paste, yeah, you might not find that.  If you search for how to convert hex to base-10 in general then you'll find plenty of examples that hopefully you can figure out how to write in whatever language you're using.  Converting between number bases is very common and part of a first-year computer science education, you'll find plenty of examples.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...