Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UTF-8 with BOM #156

Closed
gsass1 opened this issue Nov 30, 2014 · 4 comments
Closed

UTF-8 with BOM #156

gsass1 opened this issue Nov 30, 2014 · 4 comments

Comments

@gsass1
Copy link

gsass1 commented Nov 30, 2014

Hi! I was just testing out your project, I was using Visual Studio. Annoyingly it saves its UTF-8 files with a signature, called Byte Order Mark. When I run it I get this weird bug http://puu.sh/dbGIy/5b176ca61d.png. Encoding was not right, I had to save it without BOM.
What I am proposing: Could we make the documentation more clear on that only UTF-8 without BOM is supported? Or would BOM support be possible? I suppose this is a Node.JS only thing.

@jamuhl
Copy link
Member

jamuhl commented Nov 30, 2014

won't argue this. basically BOM is not recommended by utf-8 specification: http://www.unicode.org/versions/Unicode6.2.0/ch02.pdf "Use of a BOM is neither required nor recommended for UTF-8..." (section 2.6).

but will add support for it (removing that first byte on read) like:

fs.readFile(filePath, 'utf8', function (err, file) {
    if (!err) {
        if(file.charCodeAt(0) == 65279) file = file.substr(1);
    }

will add this to next version. hope that will help you.

@gsass1
Copy link
Author

gsass1 commented Nov 30, 2014

Great! Thanks.

@gsass1 gsass1 closed this as completed Nov 30, 2014
@jamuhl
Copy link
Member

jamuhl commented Dec 1, 2014

keeping this open - until done

@jamuhl jamuhl reopened this Dec 1, 2014
@jamuhl
Copy link
Member

jamuhl commented Dec 5, 2014

will be solved in next version:

2b9036c#diff-d13dac309fe497f2dcabc168bd0dcad8R26

@jamuhl jamuhl closed this as completed Dec 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants