-
Notifications
You must be signed in to change notification settings - Fork 6
Description
The default browser behavior is to open TXT files in the browser instead of downloading them, but it seems like the browser doesn't pick up the file encoding, meaning that some characters are getting mangled. The mangling only happens when you open the file in the browser, not when you download it. Example item: https://purl.stanford.edu/kc795fm0887
Steps to reproduce issue:
- Click on the "Download" button in the viewer for the txt file
- The txt file will (probably) open in a new browser tab, looking like this:

- Go back to the "Download" button and right-click + "Save link as" to download the file to your computer.
- Open the file in a text editor. It should look like this, and be identified as a UTF-8 file:

Is there a way to pass the correct encoding to the browser so that it can display the file correctly? I don't think we can assume that all files will be UTF-8, although it's probably more often true than any other encoding.
I'm basing my interpretation of the problem on this very old StackOverflow post https://stackoverflow.com/questions/13537371/displayerror-of-textfile-in-browser so maybe the issue is something else entirely.