Jump to content

[SOLVED] Integer/hexadecimal/binary to string


 Share

Recommended Posts

Hello everybody,

I have couple characters, they are A, B, C. They are converted to hexadecimal numbers: 41, 42, 43.

ABC(string) = 414243(hex) = 4276803(dec)

I want to convert for example 4276803 to string like ABC and opposite.

Sorry for my bad English. :(

 

EDIT: I found Chr and Asc functions, they are made only for characters, I need functions that would be for strings.

Edited by algiuxas

After switching years ago to Linux, sadly I don't use AutoIt anymore.

Link to comment
Share on other sites

Things aren't that simple. Look at what gives a naive approach:

Local $n = 4276803
ConsoleWrite(BinaryToString($n))
ConsoleWrite(@LF)
Local $s = "ABCdef"
ConsoleWrite(StringToBinary($s) & @LF)

Windows platforms are little-endian, which means that integers (for instance) are stored with low-order bytes first. That's why your 4276803 value gets interpreted as "CBA".

See the difference here:

Local $n = 4276803
ConsoleWrite(Hex($n) & @LF)
ConsoleWrite(Binary($n) & @LF)

If you intend to thusly process random strings then you'll have to process them in a loop, character by character. StringToASCIIArray and StringFromASCIIArray will help then.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Using the AutoIT help tool, you can easily find : BinaryToString() :

Remarks

Unlike String() which returns a hexadecimal representation of binary data, this function will assume the binary data is a string value and convert it appropriately.
See "Unicode Support" for a detailed description.

Related

Binary, IsBinary, String, StringToASCIIArray, StringToBinary

;), Alain.

Please have a look to the  JCHD's post for constructive remarks about your needs.

Edited by Grosminet
Better advice
Link to comment
Share on other sites

@Grosminet

Maybe you could read my post above to understand why this doesn't work.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

1 minute ago, Grosminet said:

Maybe have a look on timestamps for your answer and mine to avoid posting such remarks ...

I closely look and ... see nothing deserving what you say.

Also it isn't too late to edit your misleading advice.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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...