Update JSON API
[src/app-framework-demo.git] / afm-client / bower_components / jszip / documentation / limitations.md
1 ---
2 title: "Limitations of JSZip"
3 layout: default
4 section: limitations
5 fullpage: true
6 ---
7
8 ### Not supported features
9
10 All the features of zip files are not supported. Classic zip files will work
11 but encrypted zip, multi-volume, etc are not supported and the load() method
12 will throw an `Error`.
13
14
15 ### ZIP64 and 32bit integers
16
17 ZIP64 files can be loaded, but only if the zip file is not "too big". ZIP64 uses 64bits integers
18 but Javascript represents all numbers as
19 [64-bit double precision IEEE 754 floating point numbers](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf)
20 (see section 8.5). So, we have 53bits for integers and
21 [bitwise operations treat everything as 32bits](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators).
22 So if all the 64bits integers can fit into 32 bits integers, everything will be
23 fine. If it's not the case, you will have other problems anyway (see next
24 limitation).
25
26 ### Performance issues
27
28 An other limitation comes from the browser (and the machine running the
29 browser). A compressed zip file of 10MB is "easily" opened by firefox / chrome
30 / opera / IE10+ but will crash older IE. Also keep in mind that strings in
31 javascript are encoded in UTF-16 : a 10MB ascii text file will take 20MB of
32 memory.
33
34 If you're having performance issues, please consider the following :
35
36 * Don't use IE <= 9. Everything is better with typed arrays.
37 * Use typed arrays (Uint8Array, ArrayBuffer, etc) if possible :
38   * If you generate a zip file, you should use `type:"uint8array"`
39     (or blob, arraybuffer, nodebuffer).
40   * If you load the file from an ajax call, ask your XHR an ArrayBuffer.
41     Loading a string is asking for troubles.
42 * Don't use compression (see below).
43 * If you want to get the content of an ASCII file as a string, consider using
44   `asBinary()` instead of `asText()`. The transformation
45   "binary string" -> "unicode string" is a consuming process.
46
47 Note about compression :
48 When reading a file, JSZip will store the content without decompressing it.
49 When generating a compressed file, JSZip will reuse if possible compressed
50 content :
51
52 * If you read a zip file compressed with DEFLATE and call `generate` with the
53   DEFLATE compression, JSZip won't call the compression algorithms (same with
54   STORE everywhere.)
55 * If you read a zip file compressed with DEFLATE and call `generate` with the
56   STORE compression, JSZip will have to decompress everything.
57
58 On IE <=9, typed arrays are not supported and the compression algorithm
59 will fallback on arrays. In that case, JSZip needs to convert the binary string
60 into an array, DEFLATE it and convert the result into a binary string.
61 You don't want that to happen.
62
63 ### The output zip will differ from the input zip
64
65 Reading and generating a zip file won't give you back the same file.
66 Some data are discarded (file metadata) and other are added (subfolders).
67
68 ### Encodings support
69
70 JSZip only supports utf8 : if the names of the files inside the zip are not in
71 utf8 (or ASCII), they won't be interpreted correctly. If the content is a text
72 not encoded with utf8 (or ASCII), the `asText()` method won't decode it
73 correctly.