From WikiChip
Editing mirc/commands/hsave

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.

Latest revision Your text
Line 40: Line 40:
 
* 2 bytes containing the length of the following item name in bigendian format. These bytes are 0x08 0x00 for an 8-character item name
 
* 2 bytes containing the length of the following item name in bigendian format. These bytes are 0x08 0x00 for an 8-character item name
 
* The text name of the item. If the first 2 bytes were 0x08 0x00, the following 8 bytes are the name of the item.
 
* The text name of the item. If the first 2 bytes were 0x08 0x00, the following 8 bytes are the name of the item.
* 2 bytes containing the bigendian length of the following data. These bytes are 0x05 0x00 when there is a 5 byte value following these 2 bytes. The value is the number of bytes not the $len of the data. Text data value tést is UTF-8 encoded as 5 bytes and the binary format contains 0x05 0x00 even though the $len() is 4. For items containing no data, these bytes are 0x00 0x00 and and /hload -b expects these to be followed either by the length of the following itemname or end-of-file.
+
* 2 bytes containing the length of the following data value. These bytes are 0x05 0x00 when there is a 5 byte value following these 2 bytes. The value is the number of bytes not the $len of the data. Text data value tést is UTF-8 encoded as 5 bytes and the binary format contains 0x05 0x00 even though the $len() is 4.
* The bytes of the data value. There is no $crlf written to disk unless the value is a binary variable containing the $chr(13) $chr(10) bytes. Because this is binary format, there is no restriction on the contents of the item's data, so it can include 0x00's or non-UTF8 strings if created with /hadd -b, but all data created without the -b switch is UTF8 encoded.
+
* The bytes of the data value. There is no $crlf written to disk unless the value is a binary variable containing the $chr(13) $chr(10) bytes.
* Repeat the above until /hload encounters the end of file or /hsave writes the last record. There is no additional end-of-table data written to disk.
+
Repeat the above until the end of file is reached.
 
 
Any binary variable can be saved into a hashtable using 'hadd -b tablename itemname &binvarname'. If the length of the &binvar was 0-65535, it can be written to disk in /hsave -b format. However any hashtable item whose contents is length 65536 or longer will not be written to disk correctly, and no later items will be written to disk either. Instead, the length-word of the itenmame and the item name are written to disk, but no other data is written.
 
  
 
* Disk Structure: -B switch
 
* Disk Structure: -B switch
Line 50: Line 48:
 
* 4 bytes containing the length of the following item name in bigendian format. These bytes are 0x08 0x00 0x00 0x00 for an 8-byte item name
 
* 4 bytes containing the length of the following item name in bigendian format. These bytes are 0x08 0x00 0x00 0x00 for an 8-byte item name
 
* The text name of the item. If the first 4 bytes were 0x08 0x00 0x00 0x00, the following 8 bytes are the name of the item.
 
* The text name of the item. If the first 4 bytes were 0x08 0x00 0x00 0x00, the following 8 bytes are the name of the item.
* 4 bytes containing the bigendian length of the following data. These bytes are 0x40 0xe2 0x01 0x00 when there is a 123456-byte value following these 2 bytes. The value is the number of bytes not the $len of the data. Data value tést is UTF-8 encoded as 5 bytes even though the $len() is 4. The size of this value allows the following data to be larger than the 65535 limit for -b data. For items containing no data, these bytes are 0x00 0x00 0x00 0x00 and /hload -B expects these to be followed either by the length of the following itemname or end-of-file.
+
* 4 bytes containing the length of the following data value. These bytes are 0x40 0xe2 0x01 0x00 when there is a 123456-byte value following these 2 bytes. The value is the number of bytes not the $len of the data. Data value tést is UTF-8 encoded as 5 bytes even though the $len() is 4.
* The bytes of the data value. There is no $crlf written to disk unless the value is a binary variable containing the $chr(13) $chr(10) bytes. Because this is binary format, there is no restriction on the contents of the item's data, so it can include 0x00's or non-UTF8 strings if created with /hadd -b, but all data created without the -b switch is UTF8 encoded.
+
* The bytes of the data value. There is no $crlf written to disk unless the value is a binary variable containing the $chr(13) $chr(10) bytes.
* Repeat the above until /hload encounters the end of file or /hsave writes the last record. There is no additional end-of-table data written to disk.
+
Repeat the above until the end of file is reached.
 
 
Example of -b vs -B formats. Periods are added for readability only, numbers are byte values 0-255.
 
 
 
-b format
 
item name test containing the string tést
 
4 0 . 116 101 115 116 . 5 0 . 116 195 169 115 116
 
item name tést containing no data
 
5 0 . 116 195 169 115 116 . 0 0
 
 
 
-B format
 
item name test containing the string tést
 
4 0 0 0 . 116 101 115 116 . 5 0 0 0 . 116 195 169 115 116
 
item name tést containing no data
 
5 0 0 0 . 116 195 169 115 116 . 0 0 0 0
 
 
 
Note that itemnames are always written as UTF8 encoded because that's the way they were created. Item data is always UTF8 encoded, unless it was created with the -b switch, in case it contains the contents of the binvar used to create it. If a data item saved in -b format contains non-UTF8 encoded text, it loads into the item as the same binary data, but $hget(table,item) and $hget(table,item,&binvar) access the data differently.
 
 
 
-b and -B do error checking on the data when loading, stopping when encountering a bad item 'record', such as encountering end-of-file prior to the end of the record as defined by either length byte. If 0x00 is encountered in the middle of the itemname, both the item and data are hadd'ed to the table, with the itemname truncated prior to the 0x00.
 
  
 
* Disk Structure: -i switch with optional [section]
 
* Disk Structure: -i switch with optional [section]

Please note that all contributions to WikiChip may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see WikiChip:Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)