brackets-archive / bracketsIssues

Archive of issues in brackets.
0 stars 0 forks source link

[CLOSED] Incorrect default encoding in FileReader.readAsText #843

Open core-ai-bot opened 3 years ago

core-ai-bot commented 3 years ago

Issue by mikechambers Wednesday May 09, 2012 at 18:38 GMT Originally opened as https://github.com/adobe/brackets/issues/848


In NativeFileSyste.FileReader.prototype.readAsText, is the user does not specify an encoding argument, the default is set to:

"utf-8"

If you try and load a UTF 8 Encoded file using this, you will get a SECURITY_ERR (which is actually an ENCODING_ERR).

If you change the default to "utf8" or, pass in an encoding of "utf8" then everything works fine.

If you look inside of FileUtils.js, "utf8" is used.

Looking at the HTML5 FileSystem specification:

http://dev.w3.org/2006/webapi/FileAPI/#encoding-determination

Say encoding names are specified as "a character set used on the Internet [IANACHARSET]".

Looking at the IANA Charsets:

http://www.iana.org/assignments/character-sets

It appears that the string should be "UTF-8". However, this also causes the error above and does not work.

So, it looks like the default in FileReader.readAsText should be "utf8" and not "UTF-8"

It might also be worth considering create a class with constants for the major encoding types to make it less likely developers run into this, and to make it easier for us to change the encoding names in the future in case the underlying implementation changes.

core-ai-bot commented 3 years ago

Comment by pthiess Friday May 11, 2012 at 18:57 GMT


Assigned to Mike to udatee based on recent discussions

core-ai-bot commented 3 years ago

Comment by pthiess Friday May 11, 2012 at 19:09 GMT


closing this one since its superseded by #866