johnmcloud Posted December 7, 2012 Share Posted December 7, 2012 (edited) 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 December 7, 2012 by johnmcloud Link to comment Share on other sites More sharing options...
funkey Posted December 7, 2012 Share Posted December 7, 2012 (edited) $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 December 7, 2012 by funkey Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
johnmcloud Posted December 7, 2012 Author Share Posted December 7, 2012 (edited) 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 December 7, 2012 by johnmcloud Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now