david1337 Posted October 6, 2015 Posted October 6, 2015 HiWith this code I can convert a string into Hex: $String = "tdmsl" $Hex = StringRegExpReplace(StringTrimLeft(StringToBinary($String), 2),"(..)","\1 ") ConsoleWrite($Hex)The result in this example is 74 64 6D 73 6CBut how can I create a result with 00 between each "letter" so it would give this result: 74 00 64 00 6D 00 73 00 6C 00
iamtheky Posted October 6, 2015 Posted October 6, 2015 $String = "tdmsl" $Hex = StringRegExpReplace(StringTrimLeft(StringToBinary($String), 2),"(..)","\1 00 ") ConsoleWrite($Hex) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
david1337 Posted October 6, 2015 Author Posted October 6, 2015 Can't believe it was that easy... Thanks boththose !
david1337 Posted October 6, 2015 Author Posted October 6, 2015 And if I want no spaces at all like: 740064006D0073006C00?
jguinch Posted October 6, 2015 Posted October 6, 2015 (edited) Then just remove the space after \1Sorry, I didn't notice that the \1 00 becomes \100. In this case, you have to use ${1} instead of \1Another way, using \K (avoid the use of \1 or $1)$Hex = StringRegExpReplace(StringTrimLeft(StringToBinary($String), 2),"..\K","00")And another one, without using StringTrimLeft :$Hex = StringRegExpReplace(StringToBinary($String), "(?:^0x|\G)([[:xdigit:]]{2})", "${1}00") Edited October 6, 2015 by jguinch Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
iamtheky Posted October 6, 2015 Posted October 6, 2015 $String = "tdmsl" $Hex = StringStripWS(StringRegExpReplace(StringTrimLeft(StringToBinary($String), 2),"(..)","\1 00 ") , 8) ConsoleWrite($Hex) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
jguinch Posted October 6, 2015 Posted October 6, 2015 @boththose : the ${1} was missing you This can be found in the StringRegExpReplace help page (see remarks) :To separate back-reference replacements from actual (replaced) numbers, wrap them with curly braces, i.e: "${1}5". Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
jchd Posted October 6, 2015 Posted October 6, 2015 My friends, aren't you making your life more complicated than it should be?Want the UTF-16 binary image of a string?$String = "€tdmsl" $Hex = StringTrimLeft(StringToBinary($String, 2) & "", 2) ConsoleWrite($Hex & @LF)Try previous versions with non-ANSI characters, just to scratch heads. 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 hereRegExp tutorial: enough to get startedPCRE 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)
david1337 Posted October 6, 2015 Author Posted October 6, 2015 (edited) Thanks guys!Just tested them individually, and they all worked actually Edited October 6, 2015 by david1337
trancexx Posted October 6, 2015 Posted October 6, 2015 My friends, aren't you making your life more complicated than it should be?Want the UTF-16 binary image of a string?$String = "€tdmsl" $Hex = StringTrimLeft(StringToBinary($String, 2) & "", 2) ConsoleWrite($Hex & @LF)Try previous versions with non-ANSI characters, just to scratch heads.Why didn't you just hex your binary? ♡♡♡ . eMyvnE
jchd Posted October 6, 2015 Posted October 6, 2015 Yes that's true, as well and more simply. 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 hereRegExp tutorial: enough to get startedPCRE 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)
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