PureBasic Forum
https://www.purebasic.fr/english/

Data Maker for OS X & Windows
https://www.purebasic.fr/english/viewtopic.php?f=27&t=59301
Page 2 of 2

Author:  J. Baker [ Sun Dec 10, 2017 10:23 pm ]
Post subject:  Re: Data Maker for OS X & Windows

Glad to hear it's working for you. Will have to look into the extra 2 bytes for the uncompressed. Was watching a football game and haven't looked into that yet. ;)

Author:  oO0XX0Oo [ Sun Dec 10, 2017 10:30 pm ]
Post subject:  Re: Data Maker for OS X & Windows

Thanks for looking into this issue!

Code:
464c9e2702eed27169e93782b5fadc01   D:\Development\PureBasic\Test XML UTF-8 BOM - NotepadPlusPlus.xml
464c9e2702eed27169e93782b5fadc01   D:\Development\PureBasic\Test XML UTF-8 BOM - Sublime Text.xml
464c9e2702eed27169e93782b5fadc01   D:\Development\PureBasic\Test XML UTF-8 BOM - Visual Studio Code.xml


All three items are binary identical (it's their md5 checksum)...

If you want my original file for further testing (zipped "Test XML UTF-8 BOM - Sublime Text.xml")
https://workupload.com/file/fNr5YcP

Author:  J. Baker [ Sun Dec 10, 2017 11:12 pm ]
Post subject:  Re: Data Maker for OS X & Windows

Cool, thanks! Will look into it in a bit. ;)

Author:  J. Baker [ Sun Dec 10, 2017 11:29 pm ]
Post subject:  Re: Data Maker for OS X & Windows

Ok, I opened your file in HyperEdit along with mine. Yours is the first (to the left) and mine on the right. You can see the difference. One thing you can not see, due to the screen capture app, is the cursor position. Yours is on line 14, which doesn't even exist and mine is at the end of line 13. You may want to try a different editor for your xml files.

Image

Author:  oO0XX0Oo [ Sun Dec 10, 2017 11:43 pm ]
Post subject:  Re: Data Maker for OS X & Windows

What you see there is the BOM header.
EF BB BF in hex.

It seems you've written your file in UTF-8 without BOM,
mine is with UTF-8 with BOM.

Image

Author:  J. Baker [ Mon Dec 11, 2017 6:18 am ]
Post subject:  Re: Data Maker for OS X & Windows

Code removed.

Author:  wilbert [ Mon Dec 11, 2017 6:37 am ]
Post subject:  Re: Data Maker for OS X & Windows

J. Baker wrote:
You can get the MemoryStringLength() for uncompressed data and you do not have to use a -1 or set the memory length yourself. ;)

I think this does the same as using -1 for length.
Both PeekS with -1 for length and MemoryStringLength stop when a 0 is encountered to indicate the end of a string.
So both are only safe to use if you add a 0 to the uncompressed data.
Code:
Debug PeekS(?Test_XML_UTF8_BOM_xml_start, -1, #PB_UTF8)

DataSection

  Test_XML_UTF8_BOM_xml_start:
    ; size : 322 bytes
    Data.q $6C6D783F3CBFBBEF,$6E6F697372657620,$652022302E31223D,$3D676E69646F636E,$3F22382D46545522
    Data.q $746F6F523C0A0D3E,$7265562065646F4E,$2231223D6E6F6973,$6F72473C090A0D3E,$09090A0D3E737075
    Data.q $3E6563697665443C,$66453C0909090A0D,$0A0D3E7374636566,$3E6E4F3C09090909,$3C09090909090A0D
    Data.q $697461746F6E6E41,$65756C6156206E6F,$696620656854223D,$6E65766520747372,$6F6E206F64202C74
    Data.q $6D20646E69662074,$0A0D3E2F20222165,$6E4F2F3C09090909,$3C090909090A0D3E,$697461746F6E6E41
    Data.q $65756C6156206E6F,$6568746F6E41223D,$2C746E6576652072,$6E206C6C69747320,$6F2065687420746F
    Data.q $726120657720656E,$6863726165732065,$22726F6620676E69,$0909090A0D3E2F20,$7463656666452F3C
    Data.q $2F3C09090A0D3E73,$0D3E656369766544,$756F72472F3C090A,$522F3C0A0D3E7370,$3E65646F4E746F6F
    Data.b $0D,$0A,#Null
  Test_XML_UTF8_BOM_xml_end:

EndDataSection

Author:  J. Baker [ Mon Dec 11, 2017 7:28 am ]
Post subject:  Re: Data Maker for OS X & Windows

wilbert wrote:
I think this does the same as using -1 for length.

Hello wilbert!

When -1 was used on oO0XX0Oo's original posted data, it had the same effect as 322 bytes. When you use MemoryStringLength() it returned 320 bytes which oO0XX0Oo said fixed their problem. Using 2 less bytes. I would have assumed -1 had the same effect too but it is different. See this post on what I'm talking about... viewtopic.php?p=515611#p515611

Author:  wilbert [ Mon Dec 11, 2017 8:16 am ]
Post subject:  Re: Data Maker for OS X & Windows

J. Baker wrote:
When you use MemoryStringLength() it returned 320 bytes

It's just luck the data is followed by a 0. :wink:
If there's other data in the data section, it won't work.

Code:
Debug PeekS(?Test_XML_UTF8_BOM_xml_start, MemoryStringLength(?Test_XML_UTF8_BOM_xml_start, #PB_UTF8), #PB_UTF8)
Debug ""
Debug "Memory Length = " + MemoryStringLength(?Test_XML_UTF8_BOM_xml_start, #PB_UTF8)

DataSection

  Test_XML_UTF8_BOM_xml_start:
    ; size : 363 bytes
    Data.q $6576206C6D783F3C,$31223D6E6F697372,$6F636E652022302E,$5455223D676E6964,$3C0A3E3F22382D46
    Data.q $65646F4E746F6F52,$6E6F697372655620,$20200A3E2231223D,$7370756F72473C20,$2020202020200A3E
    Data.q $3E6563697665443C,$202020202020200A,$63656666453C2020,$202020200A3E7374,$2020202020202020
    Data.q $2020200A3E6E4F3C,$2020202020202020,$6E6E413C20202020,$206E6F697461746F,$54223D65756C6156
    Data.q $7473726966206568,$202C746E65766520,$6620746F6E206F64,$2221656D20646E69,$202020200A3E2F20
    Data.q $2020202020202020,$20200A3E6E4F2F3C,$2020202020202020,$746F6E6E413C2020,$6156206E6F697461
    Data.q $6F6E41223D65756C,$6576652072656874,$6C697473202C746E,$687420746F6E206C,$657720656E6F2065
    Data.q $6165732065726120,$6620676E69686372,$200A3E2F2022726F,$2020202020202020,$7463656666452F3C
    Data.q $20202020200A3E73,$63697665442F3C20,$2F3C2020200A3E65,$0A3E7370756F7247,$6F4E746F6F522F3C
    Data.b $64,$65,$3E
  Test_XML_UTF8_BOM_xml_end:
 
  MyData:
    Data.l $4A6FF65
 
EndDataSection

Author:  J. Baker [ Mon Dec 11, 2017 8:31 am ]
Post subject:  Re: Data Maker for OS X & Windows

I see. I figured it would only return per label. Not all the labels.

Should Data Maker end with a #Null then for each labels data?

Author:  wilbert [ Mon Dec 11, 2017 8:52 am ]
Post subject:  Re: Data Maker for OS X & Windows

J. Baker wrote:
I see. I figured it would only return per label. Not all the labels.

Should Data Maker end with a #Null then for each labels data?

It's only useful for text data. In case of ascii and utf8, 1 zero byte is required, in case of unicode, 2 zero bytes are required.
You could add a checkbox option to include two additional zero bytes after each file.
Another way would be to add a special option to add text. A sort of popup containing an EditorGadget where you can enter text and convert that and include the required string termination byte(s).
Or you can leave it as it is. :)

Author:  J. Baker [ Mon Dec 11, 2017 8:54 am ]
Post subject:  Re: Data Maker for OS X & Windows

wilbert wrote:
It's only useful for text data. In case of ascii and utf8, 1 zero byte is required, in case of unicode, 2 zero bytes are required.
You could add a checkbox option to include two additional zero bytes after each file.
Another way would be to add a special option to add text. A sort of popup containing an EditorGadget where you can enter text and convert that and include the required string termination byte(s).
Or you can leave it as it is. :)

Will think on it. Thanks for the information. ;)

Page 2 of 2 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/