mgmeyers / linereader Goto Github PK
View Code? Open in Web Editor NEWReads files line by line in browser using the HTML5 FileReader API.
License: MIT License
Reads files line by line in browser using the HTML5 FileReader API.
License: MIT License
Hello, your library is very good, but there are some problems related to character encoding and chunk size.
For example: when trying to read the string "Alimentação", it reads "Alimentaç��o".
I investigated and this problem is caused by the slice method (from FileReader).
The problem happens when the file is chunked exactly over an UTF-8 character that has more than one byte. UTF-8 characters are stored with 1 up to 4 bytes. The problem will not appear if every UTF-8 character of a text file has 1 byte (for example, English language).
But when you try to use other languages, like Latin languages or Asian languages like Japanese or Chinese, you will notice that slice() method may chunk in the middle of a UTF-8 character.
Later, when the strings are glued, they end up forming one or more invalid characters. One or more questions marks appears like in the example I gave above.
I don't think there is a solution for this, because slice() method works at byte level.
I read your code and run the demo with the test.txt attached in your repo. The result I got is
1: 12345678910, but the expected results should be:
1: 1
2: 2
3: 3
....
right? It seems the newlines are ignored. I don't know whether it is system dependent thing, I am using Linux.
it's a great lib
it would be great and usefull to be able to write into the soucre document
do you have anyhting like this in a smaple by any chance ?
cheers
It would be great to have this on npmjs.
Whenever this.result ends in a line break (it contains a complete line), it will be concatenated with the next line, ignoring the line break.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.