Comments (14)
Exactly what are you trying to do? The library has no native support for charsets other than UTF-8 and a basic ASCII encoding, if you want to use a different encoding you must make the transformation yourself.
from zip.js.
I get it. It seems the problem is not solved by JS :(
from zip.js.
The best solution is usually to use UTF-8 all the way through, if that is not an option, for instance because an external source provide data in a different format you'll have to write a converter. It's not that difficult, you just need a table of the Unicode values of the 256 characters in CP1251: http://en.wikipedia.org/wiki/Cp1251
For instance when you find the character with code 192 you should convert it to 0x410 (1040 in decimal), and so forth.
from zip.js.
The problem is that not always the file will be in cp1251, it can be in other encodings, but thanks for the answer!
from zip.js.
Yes Jacob is right, zip.js can't support all encodings because it's beyond its scope. The right option here is to write your own Reader and Writer constructors instead of using TextReader/TextWriter.
from zip.js.
Actually, I am wrong, there's maybe a fix (for file data) by using FileReader#readAsText 2nd parameter...
from zip.js.
I will try
from zip.js.
Thanks!
from zip.js.
Thanks for the help! Work, but not for zip.js :)
zip.js gives me already broken text.
I've used https://code.google.com/p/bitjs he gives data in Uint8Array, I've read with readAsText (bb, 'cp1251') and this work!
from zip.js.
I think I just have to change the TextWriter
constructor signature to accept a new encoding parameter and add the optional parameter here and it should be ok in zip.js :).
from zip.js.
Thanks! :)
from zip.js.
Hi!
The problem is solved for BlobReader, but when using HttpReader problem persists.
Why not use in HttpReader:
var dataView = new DataView(request.response);
that.data = new Blob([dataView], {type: request.getResponseHeader("Content-Type")});
and use as BlobReader?
And it may be need to add an additional parameter to the "charset" TextWriter to specify the encoding, and use like this? :
if(typeof charset != "undefined")
reader.readAsText(blob, charset);
else
reader.readAsText(blob);
from zip.js.
Hi :)
I may be missing something here but I don't really what's wrong with the current implementation of HttpReader constructor. There are 2 main use cases when using it:
- reading a zip file to uncompress : it's the zip binary data so the charset is not an issue
- reading a text file (or binary file) to compress : it may be a text file but it's also read as binary data because there is no need to read it as text when compressing it
Could you explain me when using "Content-Type" header is really useful?
from zip.js.
reading a zip file to uncompress : it's the zip binary data so the charset is not an issue
There is no easy way to convert the encoding but to specify when readAsText.
Could you explain me when using "Content-Type" header is really useful?
Content-Type is not strictly required (in zip.js), but improves the semantics.
And "DataView & Blob" does not apply to the Content-type, but "DataView & Blob" method to receive file from the network.
from zip.js.
Related Issues (20)
- ZIPs created via zip.js cannot be unzipped on older macOS versions with the default Archive Utility HOT 2
- [It took too much time the second time] entry getData HOT 10
- Security - CRITICAL - Unsafe dynamic method access HOT 8
- We need zip js for Angular 11 HOT 16
- RangeError [ERR_BUFFER_TOO_LARGE] occurs if the ZIP file contains a file larger than 4GB (ZIP64 format) HOT 4
- Excessive Password Prompts During Unzipping with forceZip64 and Password-Protected ZIP Creation HOT 3
- `Bun` support HOT 4
- Why doesn't this zip data work? HOT 2
- Feature: ZipReader and ZipWriter as Streams via .pipeThrough HOT 2
- Password HOT 1
- Safari 14.1.2 error -> ReferenceError: Can't find variable: zip HOT 5
- "TypeError: Cannot close a CLOSED writable stream" thrown after reading data from zip entry HOT 7
- Taking time to load HOT 3
- Range request optimalizations HOT 4
- I hope you can set the zip file comment HOT 2
- Corruption when zipping fast HOT 6
- Publish zip.js to the JSR HOT 3
- Corrupt zip file created using BlobReader on File object HOT 6
- Issues with the ZipReaderStream example HOT 2
- Cannot read properties of undefined (reading 'byteLength') HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zip.js.