Sign in to follow this  
Followers 0
theguy0000

_HexToString giving a different result than an online converter...

4 posts in this topic

I doubt anyone will want to read this complicated problem, much less help, but here goes.......

#include <String.au3>
$contents = String(FileRead(@MyDocumentsDir&"\Untitled.pdf"))
ClipPut ($contents)
$contents = _HexToString (StringTrimLeft($contents,2))
MsgBox (0, "", $contents)

Ok, so...I read the pdf file, and get this:

%PDF-1.3
%Çì¢
5 0 obj
<</Length 6 0 R/Filter /FlateDecode>>
stream
xMÍ
Â0ÑÚª«ø{¬®íO« -9öV± Th}0
î\ogB&%ÈA?Ópj5o1¶×¯ÀP.ÿ¾ñìü£AK¶¶J£{

I perform String ( ) on that to get a very long string of hex (starting with 0x).

On line 3 of the script, this hex string is copied to the clipboard.

When I paste the hex from the clipboard and into the decoder here, I get a longer string which I cannot copy to the clipboard for some reason, try it yourself with the hex:

CODE
0x255044462D312E330A25C7EC8FA20A352030206F626A0A3C3C2F4C656E6774682036203020522F46696C7

46572202F466C6174654465636F64653E3E0A73747265616D0A789C4D8CCD0AC2301084D1DAAAABF80C7BAC87AE9BED4F92A

B209E2D39F656B12054687D7F30090AEE5C86996F67422625C8413FD38F706A350E6F8831B6D7AF990798C050192E06FFBE1

FF1ECFCA3414BB6B64AA37B0093B55A573A120AC508B16FB41212F6C408F96299AC92345B1FDD130A1143956DB0881BDCA0B

B43BEC9D2741B6A292BAAD962D1788C45C7B67BEDF659371F02707170F3FA002647287F656E6473747265616D0A656E646F6

26A0A362030206F626A0A3136300A656E646F626A0A342030206F626A0A3C3C2F547970652F506167652F4D65646961426F7

8205B30203020363132203739325D0A2F526F7461746520302F506172656E742033203020520A2F5265736F75726365733C3

C2F50726F635365745B2F504446202F546578745D0A2F457874475374617465203130203020520A2F466F6E7420313120302

0520A3E3E0A2F436F6E74656E74732035203020520A3E3E0A656E646F626A0A332030206F626A0A3C3C202F54797065202F5

061676573202F4B696473205B0A34203020520A5D202F436F756E7420310A2F526F7461746520303E3E0A656E646F626A0A3

12030206F626A0A3C3C2F54797065202F436174616C6F67202F50616765732033203020520A3E3E0A656E646F626A0A37203

0206F626A0A3C3C2F547970652F4578744753746174650A2F4F504D20313E3E656E646F626A0A31302030206F626A0A3C3C2

F52370A37203020523E3E0A656E646F626A0A31312030206F626A0A3C3C2F52380A38203020523E3E0A656E646F626A0A382

030206F626A0A3C3C2F42617365466F6E742F564E5A51584C2B4C7563696461436F6E736F6C652F466F6E744465736372697

0746F722039203020522F547970652F466F6E740A2F46697273744368617220312F4C617374436861722031342F576964746

8735B20363033203630332036303320363033203630332036303320363033203630332036303320363033203630332036303

320363033203630335D0A2F456E636F64696E67203133203020522F537562747970652F54727565547970653E3E0A656E646

F626A0A31332030206F626A0A3C3C2F547970652F456E636F64696E672F42617365456E636F64696E672F57696E416E73694

56E636F64696E672F446966666572656E6365735B0A312F552F6E2F742F692F6C2F652F642F482F6F2F502F612F672F73706

163652F6F6E655D3E3E0A656E646F626A0A392030206F626A0A3C3C2F547970652F466F6E7444657363726970746F722F466

F6E744E616D652F564E5A51584C2B4C7563696461436F6E736F6C652F466F6E7442426F785B30202D3230352035373620373

7305D2F466C61677320340A2F417363656E74203737300A2F436170486569676874203737300A2F44657363656E74202D323

0350A2F4974616C6963416E676C6520300A2F5374656D562038360A2F4D697373696E675769647468203630320A2F466F6E7

446696C6532203132203020523E3E0A656E646F626A0A31322030206F626A0A3C3C2F46696C7465722F466C6174654465636

F64650A2F4C656E6774683120343634382F4C656E67746820323331393E3E73747265616D0A789CED577D5054D7153FF7BE0

F76D95DDE7D8FDD6517C1DD05212468302C0B88ABAC112483A8888A92B855C42F262A342A83E04434B1B53A1ADAAC24DA19C

536355162D434A362671CE380B5965445703295A24C4DEDD8A142A74A63DC47CF5B50C6346D93BFFA47BDBFBDF7BD73DF7BE

79EFB3BE79EBD17080098A00E38289C352725154285B560535CB6BAB47248960A00487159D53AE7D48E19DBB1A30BEBDF975

7AE58FDFCEC8B1C3EBB8C72EC8A551B960FBDCFA50188DD2B97952E3D5311391540EEC3CEF495D86118239CC1F73579CCCAD

5EBAA87DE9763B0F978554559E9901C6E0610D257975657F259640080A20CCE35A5AB970DDBF79E265756AC5D37FCFDE590F

CDAB24A6B67FE0A7C1FC7071560B007EB6DACD7054E88E327F3C5C205A1574C1673D4F5EA426885760840B358084707878B7

001BAC51CF2E2E0B72CF02338307C771106843438021FC2AFE00338CD27809DFC1CBA211506A8031A4825D442193D486FA99

FC3369244A660EF2F200B0EC2115A0E9F40327EBB506D868D500015F03A34C30FE11634C126BA57CC810192C437D2CD904F7

FCF71A8790A498201D8061F50512DC4197C06E5B01BAA8F3BA4B1F1CEEDDB730B17B85CA372734AC68D9D5EB420376794CB5

5324EA30AFD2D16AA8500FC554DE4DBB59E270AD17AE85EA886D1900B0250606085067C7295B8304E886F5A74F852C7CB05F

18E6C5DBC438A8877988CF10E43788A235C3439043EC1C1D114875EE7751048718489298EB2252F4BFE576E4ADFABBE2955B

F32579AA1344A939453C4E99B2879953E6962D64D698E12E998CDEC8E1CD628BD66699796B0C5D22276535A80D762BCCEC53

A196B16FB44CAC06BAA5BFB5E92DC6C8B64413912ABCC4E119F6F94A4B07D1253148714531953195B17CB3BC40A71BFC8A59

2663208BAE973161C23C7C8AE92AD3BB5DBBAD892B56B49F2BF16F886BE64E4816A9471ED02361006E0925D72023604687B7

00D2D0A7E24C057E0E3EB342E9B91E380D00B7A48F345CD1308CF0962185180170DFA304679A0D670A659915B5572CDD6E56

5C12EC8CE0E7AD9D9CB67FD2F8C777B5CB2E049905D9666B2435D4F0BC98E00BFA9A4A6F9C1FB01D41E40ED93050E0CE0F14

5714A78380181883A8030C6EB8033A0E78C21EDD334EDA8B5CB1B846C6FB6575626A40451BDEC46E3DD723CB68156EA387F3

ED82370C14BF48507413A39780EE78A3108FCD6D01891F0A22F41E0D32372234A5839DBC076B03063685045212206962C815

11BD31C1A736A68CC16D615D466343CA21F074C8DB25ACCBC2BDE4EDC4E392D3199DC22076E2C3AA7FE5AEDADAF25F5EF1C6

B11B8A4B97D17FFA4DA692DB1552DC799EE19ECE127A0150AA4F8A2A609C502D58328281231301D654C218A357264A6FE5E6

DD060760B5218E996CD56776ABA07E7690E135D7154DED3BAB9FEDD1F7C3861837AA7FFB6C03DBCD776F2E4154E0C46F597D

F203AF40E856D83BDFC3EBE181C9004C5BE0CCECCCC4992D39C298D37FBCC35D276698F14AECB8F8BA38A4951F47665F4330

AE5CA850D028DB1323D38C7C89290F72CABBA666BE9ED3ADB12ECF243766FC7C3211EAAFE6043C312C4F8B8444FDA9889C49

396181F17E64977A75A2D216333A2F01927C73B2D9AC44DFDE5C7BB3F2563EFD72CAF6A3AD97EEA52D3735991C94A99FB274

513D55757166F7EA3E1F09643BFF3AF5DB2F8D0F4F77EA34E5892175EE52456A25C9FB518E7B269F036EF119321026C30C5F

7AC9DC4D8720C9C8D80D1282B7A3D86E0248E8B60C460CB35CF3353B30C2213A96867D7FCBDFE2EAF374425FE5828245D1EB

48D7A98E24E8D424A39345DB430B499ABACEF38D5F9B0ED684D6BEBF637B7BCF5C5FB6FB77D4146DF2711644680967FD9C93

D1FB87549DD7C598BAA9D68533EF22BA34D337DC90D325114539E89EAAC8A4E2F219709A67453AE699EA9C65CA7179548131

8E548932CD8EC235E4627B7209D7ECD3C8DD7AA149B1661C8AB13E43470A72AB2C5A5B8523388CBC3D04A3EFFB326F5CF2AA

6B11B3D9DC1182BA9DE7F26388A1AEF55BD9D9C439CC41824D3D4BFA97FCC56DF2A20CD3124F1B06669ADBA904FE7E7831DC

6A0A59E0642EC624C742EE3629508BDAC8B9FA4A39C62930AF85CE7027E9E739975AD558C6482C8A29D32808119A82101996

CEBED6A69391B1C3216D94426FD9119565C0119237C7A3044452D46891CA255F37E87E5F8BBC4ABDFF897D3D7D5DFEEDFDB9

C39A3567DB0975CDFBA6B73FDEBDF3FAAEE3E389D8C6BE921A3FA8840F2766F7CF8D3AB9D456F7009A4A9E1E6C5A64F71064

7305159D1FF0266A1449F252C539C40154E0754CCD40B8C6A692A9C75FBDB821DA1959A8D24623AC3CCC379DC169AA9A59DE

E01EE70E0AB7342DAC080F6FA88C6581F435D46A021450C47135917AAD2143D52430B553F2D17DE097CD989DF9EC07C12879

E6790E74B58C7BDC951C9C72D1688CEE415B460D4317D3E708C31B8049731C3DAE491FCE8C77452D56543ED2D5A3C467F1E7

DC11FCA629674B7D34EE2E5D042924FB46EBB433CADB3FC819FF193DB6EA93F0EDAE9F14DAF7606B3D0BE728CBC721CDF005

1E0F38D2B0A2B32508F314BC935E62B7E5AC48B8A22EA8D0A707A1924225964C68DE70AB9468EE76CDA8AE8F287D683E640E

217E2406618695AFB0CE698B461B7D1F2BBEA5DA2FCF52E91D5BB77773536EEC26A2729448FF92545BDA2FE431D50AF04BAC

FB77677B79EEFD638DD8276CD1424B46AB2CF29F10E3E85CFE679294C31EAB2C3450B2E8908108C8CE9C3049B6D849236AF9

6D65B424B146F1FE7158D79749FCBE2C28C12A5E5147E66607BFF476A3F91CE931ED5119598B3A57603893ED24F8D813B770

2C10EFFB4E87131A13D80E55B22E73BA1EA6B687E8CFE6F06991FC201729FDCA7F3117521EC437473CF3D46C5533CC5533CC

5FF12A1BC49874F5366FCDFD28E52D15871630C99B3E717CC7A292FB9C89D93CF99E1FFAEF0E00DB5BCC64F5F049E96A18F6

82DCA3CB699301BE6E3B97716BC047978122E0237FE5FE0360086C8C21306728B1B0C1071170B05EBCBCA97963AA756AC595

BB16A99A693D4E35EE4DB16DD93621FF40D3ED1317C22E6DBC9D061F8BF97E6EF84C0D770EB31F6FC1B6C0B6113EC44D4228

E3CC6093CF73FC21680A1B8FB0F25341D1F1C3F76F4F422C97B0F0C43641C926B62B5EBF135D25600B5906F170B51343E9AF

E3F013DDF38560A656E6473747265616D0A656E646F626A0A322030206F626A0A3C3C2F50726F6475636572284146504C204

7686F737473637269707420382E3534290A2F4372656174696F6E4461746528443A3230303631313138313830383438290A2

F4D6F644461746528443A3230303631313138313830383438290A2F5469746C6528556E7469746C6564202D204E6F7465706

164290A2F43726561746F72285072696D6F50444620687474703A2F2F7777772E7072696D6F7064662E636F6D290A2F41757

4686F72284D61747420526F7468293E3E656E646F626A0A787265660A302031340A303030303030303030302036353533352

066200A30303030303030343932203030303030206E200A30303030303033353637203030303030206E200A3030303030303

0343234203030303030206E200A30303030303030323634203030303030206E200A303030303030303031352030303030302

06E200A30303030303030323435203030303030206E200A30303030303030353430203030303030206E200A3030303030303

0363431203030303030206E200A30303030303030393630203030303030206E200A303030303030303538312030303030302

06E200A30303030303030363131203030303030206E200A30303030303031313635203030303030206E200A3030303030303

0383436203030303030206E200A747261696C65720A3C3C202F53697A65203134202F526F6F74203120302052202F496E666

F2032203020520A2F4944205B3C33313734383844393538313438453845444344434446344345413541304330433E3C33313

734383844393538313438453845444344434446344345413541304330433E5D0A3E3E0A7374617274787265660A333736360

A2525454F460A

Ok, so that's fine. Now How can I get that into my AutoIt Script? Well, the first thing that should come to mind is _HexToString ( ). Right? of course, that's what the online converter did right? so _HexToString should do the same thing. Well, it doesn't.

_HexToString of the same hex used on the site, gave this when using _HexToString:

%PDF-1.3
%Çì¢
5 0 obj
<</Length 6 0 R/Filter /FlateDecode>>
stream
xMÍ
Â0ÑÚª«ø{¬®íO« -9öV± Th}0
î\ogB&%ÈA?Ópj5o1¶×¯ÀP.ÿ¾ñìü£AK¶¶J£{

;) look farmiliar? Of course it does! It's the same Text originally read from the file in the first place!! :lmao::evil::mad:

Why on earth is _HexToString giving a different output than an online Hex converter?


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites



$s = FileRead('Some.pdf')
ConsoleWrite($s)
;The above wrote correctly
$s = BinaryString(FileRead('Some.pdf'))
ConsoleWrite($s)
;The above wrote the same
$s = Hex(BinaryString(FileRead('Some.pdf')))
ConsoleWrite($s)
;The above wrote hex
$s = Hex(BinaryString(FileRead('Some.pdf')))
ConsoleWrite(BinaryString('0x' & $s))
;The above translated correctly
$s = Hex(FileRead('Some.pdf'))
ConsoleWrite(BinaryString('0x' & $s))
;The above translated correctly


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

$s = FileRead('Some.pdf')
ConsoleWrite($s)
;The above wrote correctly
$s = BinaryString(FileRead('Some.pdf'))
ConsoleWrite($s)
;The above wrote the same
$s = Hex(BinaryString(FileRead('Some.pdf')))
ConsoleWrite($s)
;The above wrote hex
$s = Hex(BinaryString(FileRead('Some.pdf')))
ConsoleWrite(BinaryString('0x' & $s))
;The above translated correctly
$s = Hex(FileRead('Some.pdf'))
ConsoleWrite(BinaryString('0x' & $s))
;The above translated correctly
hmmmm, all of those gace me the same result, except one. The one that you said converts to hex. That one actually does convert to hex.

Ok, so I got hex. pretty good so far. Now, the problem is translating that hex to text.

The online converter mentioned in my first post works great. But, performing _HexToString with the SAME hex string, _HexToString gives me a different result than the online converter.

Any idea why?


The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

hmmmm, all of those gace me the same result, except one. The one that you said converts to hex. That one actually does convert to hex.

Ok, so I got hex. pretty good so far. Now, the problem is translating that hex to text.

The online converter mentioned in my first post works great. But, performing _HexToString with the SAME hex string, _HexToString gives me a different result than the online converter.

Any idea why?

I had the same result as the online converter you mentioned when I converted using the Hex part and then the BinaryString('0x' & $HexCode)... so no, I have no idea.

Actually, I have no idea what you think the output is supposed to be.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
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
Sign in to follow this  
Followers 0