Jump to content

[SOLVED] Binary-Hex-String


Recommended Posts

Hi guys,

I have a problem to convert a string to binary-hex and viceversa:

This is an example, i have take the value from the registry:

$BasicString = "0xF4FFFFFF000000000000000000000000900100000000000100000500"
$MaxLenght = "186"

$TimesNewRoman_Bin_Complete = "0xF4FFFFFF000000000000000000000000900100000000000100000500540069006D006500730020004E0065007700200052006F006D0061006E0000000000000000000000000000000000000000000000000000000000000000000000"
$TimesNewRoman_Bin = "540069006D006500730020004E0065007700200052006F006D0061006E"
$TimesNewRoman_String = "Times New Roman"

$SegoeUI_Bin_Complete = "0xF4FFFFFF0000000000000000000000009001000000000001000005005300650067006F006500200055004900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
$SegoeUI_Bin = "5300650067006F0065002000550049"
$SegoeUI_String = "Segoe UI"

I have try to convert in many way, but i have always different result. My goal is convert $SegoeUI_String to $SegoeUI_Bin and viceversa.

Thanks for any help ;)

Edited by johnmcloud
Link to comment
Share on other sites

$SegoeUI_Bin = "5300650067006F0065002000550049"
$SegoeUI_String = "Segoe UI"

$a = BinaryToString("0x" & StringReplace($SegoeUI_Bin, "00", ""))
ConsoleWrite($a & @CRLF)

Edit: Or

$SegoeUI_Bin = "5300650067006F0065002000550049"
$SegoeUI_String = "Segoe UI"
$a = BinaryToString("0x00" & $SegoeUI_Bin, 3)
ConsoleWrite($a & @CRLF)
Edited by funkey

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

Thanks, working ;)

Last question, any idea how to fill the string with a x numbers of zero?

$SegoeUI_Bin_Complete = "0xF4FFFFFF0000000000000000000000009001000000000001000005005300650067006F006500200055004900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
$BasicString = "0xF4FFFFFF000000000000000000000000900100000000000100000500"
$MaxLenght = "186"

;~ $SegoeUI_Bin = "5300650067006F0065002000550049"
;~ $BinToString = BinaryToString("0x00" & $SegoeUI_Bin, 3)

$SegoeUI_String = "Segoe UI"
$StringToBin = StringTrimLeft(StringToBinary($SegoeUI_String, 3), 4)
$temp = $BasicString & $StringToBin
$zeros = $MaxLenght - StringLen($temp) ; numbers of zero to add

ConsoleWrite($temp & @CRLF)
ConsoleWrite($zeros & @CRLF)

EDIT: Solved with _StringRepeat ;)

Edited by johnmcloud
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...