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
[Bug] i.fusion.hpf - change file encoding from us-ascii to utf-8 #525
Comments
though not sure when looking at other addons, e.g.
source downloaded via zip file from github |
I have done a full repo check and grouped and counted files with identical encoding:
Likely it should be streamlined... |
lets have closer look into the files
these quotings are suspicious:
|
bingo, these suspicious quotes causes the crash mentioned in OSGeo/grass#1496 (comment) with these quotes
this line.replace mechanism also used by g.extension works now. so no file encoding change is needed for a working i.fusion.hpf installation in winGRASS; only quote types should be changed. in a long term, encoding streamlining should be discussed. |
I have changed such characters in #526, please try. |
would the following change of # replace:
with fileinput.FileInput(filename, inplace=True) as file:
# with:
with fileinput.FileInput(filename, inplace=True, openhook=fileinput.hook_encoded("utf-8")) as file: |
THanks for the suggestion @nilason . Unfortunately, openhook is not supported with inplace editing: But I also think it could/should be adressed at that line in I could add such a solution to OSGeo/grass#1565 hopefuly a bit later today... |
With this function for shebang replacement:
|
Sorry for the late reply. Indeed, these quotes likely come from a copy-paste from some webpage. |
I will have to go through the whole conversation. Is it only the erroneous quotes that have to be 'fixed'? |
Yes |
Just installed |
Erasing the double quotes, and adding new double quotes, supposedly "normal" ones, does not show any |
I have done some change to the quotes, naive replacement to single quotes, then back to double quotes, hopefully correct ones. I don't know if it's possible to make a cherry-pick pull request. I guess I will have to create a new branch, roll back the commits I did in master, and only re-apply changes of interest (here: changes that concern the 'quotes' issue). Then re-do a pull request. Is that right? Can someone confirm? |
I guess no. Because the the proposed changes here, e.g. in |
Which PR do you refer to? |
To return to the original reported issue of ascii vs. utf-8 encoding of files. UTF-8 is fully compatible with ASCII, to quote wikipedia: "It was designed for backward compatibility with ASCII: the first 128 characters of Unicode, which correspond one-to-one with ASCII, are encoded using a single byte with the same binary value as ASCII, so that valid ASCII text is valid UTF-8-encoded Unicode as well." With this in mind I found it suspect that echo "asdf“" > a.txt | file -i a.txt
a.txt: text/plain; charset=utf-8
echo "asdf" > b.txt | file -i b.txt
b.txt: text/plain; charset=us-ascii ... suggests that I'd say there is probably no problem in general with the file encodings in the code base, but on Windows there are cases when reading python files doesn't default on assuming "utf-8". This has to be explicitly requested. The English style quoting character |
Hmm? Not sure why I don't see a diff. |
An 'old' draft -- #510 |
I believe this ticket may be closed as 'invalid'. See #525 (comment). |
Closing it after @nilason's suggestion. Thanks! |
Name of the addon
i.fusion.hpf
it seems not all text/python files in the i.fusion.hpf source are utf-8 encoded
this causes a g.extension crash in winGRASS
Expected behavior
no g.extension error
solution
encoding of files should changed to utf-8
The text was updated successfully, but these errors were encountered: