CrypticKiwi Posted September 26, 2015 Share Posted September 26, 2015 (edited) Hello guys, i have this file containing data like LÖS7Õ¿—ÑëÜzþš‡gËÑ and i would like to convert it to binary base two (8 bits per char) and back, example Ü base two is 11011100this website Link does that conversion on some of the characters only and i am wondering if this can possibly be done using autoit?Thank you Edited September 26, 2015 by CrypticKiwi Link to comment Share on other sites More sharing options...
Developers Jos Posted September 26, 2015 Developers Share Posted September 26, 2015 (edited) I have this bit of code but see that not all characters are returning the same bits which could be due to the codepage or something. I leave it to you to do the debugging on that. $iS = "LÖS7Õ¿—ÑëÜzþš‡gËÑ" $iH = StringMid(StringToBinary($iS), 3) $bit2out = "" For $x = 1 To StringLen($iH) $cc = Dec(StringMid($iH, $x, 1)) For $y = 3 To 0 Step -1 If BitAND($cc, 2 ^ $y) Then $bit2out &= "1" Else $bit2out &= "0" EndIf Next Next ConsoleWrite('Binary 2 = ' & $bit2out & @CRLF) EDIT: Using another site (http://software.ellerton.net/txt2bin/) to convert your string I get a longer returned Base2 for the characters in error:L=01001100 Ö=11010110 S=01010011 7=00110111 Õ=11010101 ¿=10111111 —=10000000010100 Ñ=11010001 ë=11101011 Ü=11011100 z=01111010 þ=11111110 š=101100001 ‡=10000000100001 g=01100111 Ë=11001011 Ñ=11010001 Jos Edited September 26, 2015 by Jos Typos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Danyfirex Posted September 26, 2015 Share Posted September 26, 2015 (edited) I edit an Ascend4nt's code and got this:_StringToBase('LÖS7Õ¿—ÑëÜzþš‡gËÑ') Func _StringToBase($sString) Local $iTopBit,$sBinString = "" Local $iUnsignedNumber=0 ; Maximum 32-bit # range is -2147483648 to 4294967295 For $i= 1 to StringLen($sString) ; Any number <0 or >2147483647 will have the 32nd (top) bit set $iNumber= Asc(StringMid($sString,$i,1)) If $iNumber<-2147483648 Or $iNumber>4294967295 Then Return SetError(1,0,"") If $iNumber>2147483647 Or $iNumber<0 Then $iTopBit=1 Else $iTopBit=0 EndIf ; Remove topbit, otherwise the function will enter an endless loop $iUnsignedNumber=BitAND($iNumber,0x7FFFFFFF) ; Cycle through each bit, shifting to the right until 0 Do $sBinString = BitAND($iUnsignedNumber, 1) & $sBinString $iUnsignedNumber = BitShift($iUnsignedNumber, 1) Until Not $iUnsignedNumber ConsoleWrite(chr($iNumber) & "=" & Stringright($iTopBit & StringRight("000000000000000000000000000000" & $sBinString,31),8) & @CRLF) $sBinString="" Next EndFunc ;==>_NumberToBinaryOutput:L=01001100 Ö=11010110 S=01010011 7=00110111 Õ=11010101 ¿=10111111 —=10010111 Ñ=11010001 ë=11101011 Ü=11011100 z=01111010 þ=11111110 š=10011010 ‡=10000111 g=01100111 Ë=11001011 Ñ=11010001Saludos Edited September 26, 2015 by Danyfirex CrypticKiwi 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
CrypticKiwi Posted September 26, 2015 Author Share Posted September 26, 2015 i have been searching all night for a solution and you guys as always there to the rescue!!so i see a pattern here, if i ask for anything on this forum i get it! maybe next time ill try ask for a million dollars! this is GREAT WORK DANY with one slight issue, i cant do anything with it without the reverse, to text, 11011100 = Ü i tried to do it myself but its not easy...this really really appreciated thank you guys Link to comment Share on other sites More sharing options...
Danyfirex Posted September 26, 2015 Share Posted September 26, 2015 I'll look into later. right now I'm at work :S.Regards-Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Gianni Posted September 26, 2015 Share Posted September 26, 2015 (edited) ? something like this?Local $sString = "LÖS7Õ¿—ÑëÜzþš‡gËÑ", $sChar, $sBase2 For $i = 1 To StringLen($sString) $sChar = StringMid($sString, $i, 1) ; from decimal to binary (base 2) $sBase2 = _Dec_To_Bin(Asc($sChar)) ; from binary back to decimal _Bin_To_Dec() ConsoleWrite($sChar & @TAB & $sBase2 & @TAB & Chr(_Bin_To_Dec($sBase2)) & @CRLF) Next Func _Dec_To_Bin($iNumber) ; from decimal to binary ; http://www.autoitscript.com/forum/topic/90056-decimal-to-binary-number-converter/?p=647505 Local $sBinString = "" While $iNumber $sBinString = BitAND($iNumber, 1) & $sBinString $iNumber = BitShift($iNumber, 1) WEnd ; limit returned value to 8 bit 0 - 255 Return StringRight("00000000" & $sBinString, 8) EndFunc ;==>_Dec_To_Bin Func _Bin_To_Dec($BinNum) ; from binary to decimal Local $dec = 0 For $i = 0 To StringLen($BinNum) - 1 $dec += 2 ^ $i * StringMid($BinNum, StringLen($BinNum) - $i, 1) Next Return $dec EndFunc ;==>_Bin_To_Dec Edited September 26, 2015 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... 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