-
-
Notifications
You must be signed in to change notification settings - Fork 368
iteration: fall back to UTF-8 (not windows-1252) if encoding uncertain #346
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # The first 1024 bytes of this file need to contain only ASCII characters. | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Of two minds. On the one hand, this is a test that knows a little too much about the implementation of the code it's testing (1024 bytes). On the other hand, this is a real thing that happened and mangled my submission and someone else's, so it is not unwarranted. |
||
| # After the first 1024 bytes, then there should be a non-ASCII character. | ||
| # | ||
| # Explanation: | ||
| # We use golang.org/x/net/html/charset.DetectEncoding to guess file encoding. | ||
| # DetectEncoding checks the first 1024 bytes of a file. | ||
| # If it can't determine the encoding and saw no non-ASCII characters, | ||
| # it declares the file to have windows-1252 encoding. | ||
| # This mangles the submitted file if it should have been UTF-8. | ||
| # We test to make sure we use UTF-8 for such files, instead of windows-1252. | ||
|
|
||
| lipsum = """ | ||
| Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam condimentum vitae | ||
| ipsum eget tempor. Morbi sed ex quis orci vulputate cursus quis non massa. | ||
| Vestibulum quam nibh, elementum in justo in, venenatis tristique nisl. Morbi | ||
| sagittis elit id velit ultricies, sed rutrum augue posuere. Donec nec nulla nec | ||
| eros fringilla pellentesque. Duis at dictum justo. Nunc ut magna felis. Aliquam | ||
| volutpat, lectus et molestie porttitor, est orci malesuada erat, ac pretium | ||
| eros ligula vel erat. Nullam venenatis dui eget sapien semper lobortis. Aenean | ||
| ac eros eget neque porta auctor in nec erat. Phasellus ac nulla ac turpis | ||
| porttitor auctor. Etiam eget posuere diam, ac feugiat lacus. Curabitur ornare | ||
| justo ut nulla congue, vitae posuere erat venenatis. Aliquam pulvinar eleifend | ||
| faucibus. | ||
|
|
||
| Etiam justo sem, faucibus malesuada purus a, ultrices efficitur ex. | ||
| Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac | ||
| turpis egestas. Duis maximus dapibus mattis. Quisque sem ex, convallis eu | ||
| ultricies posuere. | ||
| """ | ||
|
|
||
| # 👍 | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The consequence of replacing this line with
if true:And the consequences of replacing with
if false(as if I never wrote this code):