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

No way to override UTF-8 BOM stripping #72

Closed
RedactedHash opened this issue Jun 29, 2015 · 12 comments
Closed

No way to override UTF-8 BOM stripping #72

RedactedHash opened this issue Jun 29, 2015 · 12 comments

Comments

@RedactedHash
Copy link

Having been working with gulp (and vinyl-fs by proxy) for a while now, I have become aware that vinyl-fs strips the BOM from UTF-8 files. This is currently completely undocumented (except a footnote in the changelog) and yet potentially effects any system that needs to have BOM present in output files. (IIS / ASP.NET is an example that can occasionally be picky with the output of UTF8 files that lack BOM.) Providing users with a flag to override this behavior would be helpful for these edge cases.

@RedactedHash RedactedHash changed the title No way to override BOM stripping No way to override UTF-8 BOM stripping Jun 29, 2015
@yocontra
Copy link
Member

@sindresorhus any comment?

@yocontra
Copy link
Member

@IsaacSanch Will get this resolved 👍

@yocontra
Copy link
Member

Oops meant to ping @mathiasbynens

@sindresorhus
Copy link

The BOM in UTF-8 has no meaning.

This is currently completely undocumented

It's normal to remove the BOM as it conflicts with many things, like JSON.parse, etc. You should just get in the habit of assuming it's getting stripped. Even Node does this when you require files.

Providing users with a flag to override this behavior would be helpful for these edge cases.

👎 Just add it back if you need it. There really shouldn't be a flag for something like this.

@yocontra
Copy link
Member

Adding my comment from the commit here for visibility -

@sindresorhus Not adding it just because it was asked for, adding it because it makes sense. We shouldn't be fucking with contents without a way to disable it or we are a really shitty general purpose fs access tool (vinyl-fs)

@sindresorhus
Copy link

@contra The strip BOM functionality is fixing a bug for users. UTF-8 shouldn't have a BOM. Now every gulp plugin will have to handle BOM stripping in case stripBOM: false...

@phated
Copy link
Member

phated commented Jun 30, 2015

👍 with @sindresorhus here - we should always remove when encoding is utf8

@yocontra
Copy link
Member

If this is an opinionated view we want to take on reading files then it needs to be documented

@yocontra
Copy link
Member

Resolution: Use something prior to .dest to add the BOM back to your files if you encounter this edge-case. https://www.npmjs.com/package/vinyl-map is a good place to start 👍

When you come up with working code please post it here so others can see it.

@phated
Copy link
Member

phated commented Jun 30, 2015

Probably just create the inverse of https://www.npmjs.com/package/gulp-stripbom

@sindresorhus
Copy link

@phated Yup, was going to suggest that.

Done: https://github.com/sindresorhus/gulp-bom

@yocontra
Copy link
Member

Locking since this is resolved 👍

@gulpjs gulpjs locked and limited conversation to collaborators Jun 30, 2015
phated pushed a commit that referenced this issue Nov 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants