Difference between revisions of "ZIM file format"

Jump to navigation Jump to search
Line 2: Line 2:
The '''ZIM file format''' is based on the old and deprecated [[Zeno File Format]].See also a walk through an example at [[ZIM File Example]].
The '''ZIM file format''' is based on the old and deprecated [[Zeno File Format]].See also a walk through an example at [[ZIM File Example]].
It starts with a header, which is described here:
It starts with a header, which is described here:
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== Header ==
== Header ==
Line 7: Line 11:


Length in byte, all types are littlendian.
Length in byte, all types are littlendian.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


{|{{Prettytable}}
{|{{Prettytable}}
Line 35: Line 43:
| checksumPos || integer || 72 || 8 || pointer to the md5checksum of this file without the checksum itself. This points always 16 bytes before the end of the file.
| checksumPos || integer || 72 || 8 || pointer to the md5checksum of this file without the checksum itself. This points always 16 bytes before the end of the file.
|}
|}
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== MIME Type List (mimeListPos) ==
== MIME Type List (mimeListPos) ==
Line 40: Line 52:


The MIME types in this list are zero terminated strings. An empty string marks the end of the MIME type list.
The MIME types in this list are zero terminated strings. An empty string marks the end of the MIME type list.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


{|{{Prettytable}}
{|{{Prettytable}}
Line 52: Line 68:
| <last entry / end> || string || n/a ||zero terminated|| empty string - end of MIME type list         
| <last entry / end> || string || n/a ||zero terminated|| empty string - end of MIME type list         
|}
|}
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== URL Pointer List (urlPtrPos) ==
== URL Pointer List (urlPtrPos) ==
Line 59: Line 79:


Since directory entries have variable sizes this is needed for random access.
Since directory entries have variable sizes this is needed for random access.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


{|{{Prettytable}}
{|{{Prettytable}}
Line 73: Line 97:


Zimlib caches directory entries and references the cached entries via the URL pointers.
Zimlib caches directory entries and references the cached entries via the URL pointers.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== Title Pointer List (titlePtrPos) ==
== Title Pointer List (titlePtrPos) ==
Line 78: Line 106:
in the URL pointer list. Note that the title pointers are only 4 bytes. They are not offsets in the file but article numbers.
in the URL pointer list. Note that the title pointers are only 4 bytes. They are not offsets in the file but article numbers.
To get the offset of an article from the title pointer list, you have to look it up in the URL pointer list.
To get the offset of an article from the title pointer list, you have to look it up in the URL pointer list.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


{|{{Prettytable}}
{|{{Prettytable}}
Line 94: Line 126:
* the pointer list is only half in size as 4 bytes are enough for each entry
* the pointer list is only half in size as 4 bytes are enough for each entry
* accessing directory entries by title also makes use of cached directory entries which are referenced by the URL pointers, as implemented in zimlib.
* accessing directory entries by title also makes use of cached directory entries which are referenced by the URL pointers, as implemented in zimlib.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== Directory Entries ==
== Directory Entries ==
Line 99: Line 135:


There are two types of directory entries: article entries and redirect entries. If the first two bytes are 0xffff the directory entry is a redirect.
There are two types of directory entries: article entries and redirect entries. If the first two bytes are 0xffff the directory entry is a redirect.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


=== Article Entry ===
=== Article Entry ===
Line 122: Line 162:
| parameter || data || ||see parameter len|| (not used) extra parameters                         
| parameter || data || ||see parameter len|| (not used) extra parameters                         
|}
|}
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


=== Redirect Entry ===
=== Redirect Entry ===
Line 143: Line 187:
| parameter || data || ||see parameter len|| (not used) extra parameters                         
| parameter || data || ||see parameter len|| (not used) extra parameters                         
|}
|}
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== Cluster Pointer List (clusterPtrPos) ==
== Cluster Pointer List (clusterPtrPos) ==
Line 158: Line 206:
| ... || integer || ... || 8 || ...                           
| ... || integer || ... || 8 || ...                           
|}
|}
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== Clusters ==
== Clusters ==
Line 165: Line 217:


To find the data of a specific directory entry within a cluster the uncompressed cluster has a list of pointers to blobs within the uncompressed cluster after the first byte.
To find the data of a specific directory entry within a cluster the uncompressed cluster has a list of pointers to blobs within the uncompressed cluster after the first byte.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


{|{{Prettytable}}
{|{{Prettytable}}
Line 191: Line 247:


The offset addresses uncompressed data. The last pointer points to the end of the data area. So there is always one more offset than blobs. Since the first offset points to the start of the first data, the number of offsets can be determined by dividing this offset by 4. The size of one blob is calculated by the difference of two consecutive offsets.
The offset addresses uncompressed data. The last pointer points to the end of the data area. So there is always one more offset than blobs. Since the first offset points to the start of the first data, the number of offsets can be determined by dividing this offset by 4. The size of one blob is calculated by the difference of two consecutive offsets.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== Namespaces ==
== Namespaces ==
Line 196: Line 256:


They can be distinguished by prepending the article namespace before the article name in the URL path, eg. ''http://localhost/A/Articlename''.
They can be distinguished by prepending the article namespace before the article name in the URL path, eg. ''http://localhost/A/Articlename''.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


{|{{Prettytable}}
{|{{Prettytable}}
Line 220: Line 284:
| X || fulltext index - see [[ZIM Index Format]]         
| X || fulltext index - see [[ZIM Index Format]]         
|}
|}
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== URLs ==
== URLs ==
Line 228: Line 296:


The URLs in the UrlPointerlist are not encoded. Some readers process the requests that already do the decoding internally whereas most readers will handle the URLs directly. In this case you have to do the decoding before you pass the parameter to zimlib, but zimlib already provides a method to do so.
The URLs in the UrlPointerlist are not encoded. Some readers process the requests that already do the decoding internally whereas most readers will handle the URLs directly. In this case you have to do the decoding before you pass the parameter to zimlib, but zimlib already provides a method to do so.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


=== Local Anchors ===
=== Local Anchors ===
Line 241: Line 313:


Should you render the article contents by yourself you have to consider this and take care of it before you hand requests to zimlib.
Should you render the article contents by yourself you have to consider this and take care of it before you hand requests to zimlib.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== Encodings ==
== Encodings ==
Line 247: Line 323:


Old Zeno files used a mixture of Latin1 and UTF-8 so there is still some "auto detection" code left in the ''zimlib'', a workaround for this bug. This will be removed in future versions. Zeno files are not supported anymore.
Old Zeno files used a mixture of Latin1 and UTF-8 so there is still some "auto detection" code left in the ''zimlib'', a workaround for this bug. This will be removed in future versions. Zeno files are not supported anymore.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


=== Integer Encoding ===
=== Integer Encoding ===
Line 254: Line 334:


Old Zeno files used the QUnicode library instead. By switching to UTF-8 the new format is more standard-adherent and easier to understand.
Old Zeno files used the QUnicode library instead. By switching to UTF-8 the new format is more standard-adherent and easier to understand.
'''Source(s):'''  [http://www.downloadranking.com  ZIM file format]


== See also ==
== See also ==