Jump to content

Hex to Char. how to?


Recommended Posts

+ isn't 0xbb.. + is 0x2b

MsgBox(0,"",Chr(0x2b)) ;+

Search in AutoIt help for "ASCII Characters"

Sites are giving me different values for hex than the autoit helpfile,

http://msdn2.microsoft.com/en-us/library/ms645540.aspx

http://www.kbdedit.com/manual/low_level_vk_list.html

EDIT

also Chr ( ASCIIcode ) uses the ASCII Code, not the hex values, is there any way to make it use the hex values?

Re-Edit

why doesnt this work then?

$Chr = StringSplit("0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A", ",");Hex
;$Chr = StringSplit("65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57", ",");Ascii

for $i = 1 to $Chr[0]
    MsgBox(0,"",$Chr[$i] & " = " & Asc($chr[$i]))
Next
Edited by ReaImDown
[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Link to comment
Share on other sites

Is this what you wanted it to do?

$Chr = StringSplit("0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A", ",");Hex
;$Chr = StringSplit("65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57", ",");Ascii

for $i = 1 to $Chr[0]
    MsgBox(0,"",$Chr[$i] & " = " & Chr(Dec(StringRight($Chr[$i],2))))
Next

Both those links you posted have the same values listed as the help file as well.. So I'm not sure what you were looking at, unless I'm missing something.. Try looking at this page, it's the one I use, and it might be easier to understand since you can see the hex and decimal/ascii values side by side: http://asciitable.com/

Link to comment
Share on other sites

Is this what you wanted it to do?

$Chr = StringSplit("0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A", ",");Hex
;$Chr = StringSplit("65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57", ",");Ascii

for $i = 1 to $Chr[0]
    MsgBox(0,"",$Chr[$i] & " = " & Chr(Dec(StringRight($Chr[$i],2))))
Next

Both those links you posted have the same values listed as the help file as well.. So I'm not sure what you were looking at, unless I'm missing something.. Try looking at this page, it's the one I use, and it might be easier to understand since you can see the hex and decimal/ascii values side by side: http://asciitable.com/

why the StringRight?

also, I found _HexToString() works too

[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Link to comment
Share on other sites

why doesnt this work then?

$Chr = StringSplit("0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A", ",");Hex
;$Chr = StringSplit("65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57", ",");Ascii

for $i = 1 to $Chr[0]
    MsgBox(0,"",$Chr[$i] & " = " & Asc($chr[$i]))
Next
Because you introduced funky white space into your values. The first value in your array is "0x41", but the second is "{SPACE}0x42".

Also, the Asc() function returns an ASCII value, it doesn't take one as input. You wanted Chr():

$Chr = StringSplit("0x41, 0x42, 0x43, 0x44", ",");Hex

for $i = 1 to $Chr[0]
    ConsoleWrite($Chr[$i] & " = " & Chr(StringStripWS($chr[$i], 8)) & @LF)
Next

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Because you introduced funky white space into your values. The first value in your array is "0x41", but the second is "{SPACE}0x42".

Also, the Asc() function returns an ASCII value, it doesn't take one as input. You wanted Chr():

$Chr = StringSplit("0x41, 0x42, 0x43, 0x44", ",");Hex

for $i = 1 to $Chr[0]
    ConsoleWrite($Chr[$i] & " = " & Chr(StringStripWS($chr[$i], 8)) & @LF)
Next

:D

I use

_hextostring($chr[$I])

[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Link to comment
Share on other sites

I use

_hextostring($chr[$I])

Using what you had just produces errors because _hextostring() doesn't accept spaces or "0x" in the input hex.

This:

#include <string.au3>

$Chr = StringSplit("0x41, 0x42, 0x43, 0x44", ",");Hex

for $i = 1 to $Chr[0]
    ConsoleWrite($Chr[$i] & " = " & _HexToString($chr[$i]) & @LF)
Next

Outputs this:

0x41 = -1
 0x42 = -1
 0x43 = -1
 0x44 = -1

That doesn't work unless you reformat the input (but I'll assume you did and got it working).

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Using what you had just produces errors because _hextostring() doesn't accept spaces or "0x" in the input hex.

This:

#include <string.au3>

$Chr = StringSplit("0x41, 0x42, 0x43, 0x44", ",");Hex

for $i = 1 to $Chr[0]
    ConsoleWrite($Chr[$i] & " = " & _HexToString($chr[$i]) & @LF)
Next

Outputs this:

0x41 = -1
 0x42 = -1
 0x43 = -1
 0x44 = -1

That doesn't work unless you reformat the input (but I'll assume you did and got it working).

:D

yup, I went and replaced " 0x" with "" :P Thanks for your help all ;)
[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...