Python files etc. with encoding comment (PEP263) open wrong as UTF-8 always. "Stage selected ranges" false-uses UTF-8 even when enc changed #116639
Labels
*duplicate
Issue identified as a duplicate of another issue(s)
Steps to Reproduce:
Create Python file with encoding magic comment ( PEP263 ) in first or second line. E.g.
Open the file in VSCode => The encoding shown in status line (bottom right) is always wrong as
UTF-8
and nonsense chars are displayed. In practice this causes a great mix up - particularly when there are only few beyond ASCII chars and you don't notice it problem for long. I have many files (e.g. stuff migrated from Python 2 which had no UTF8 default, rather a LATIN-1 fall back) which do not use UFT-8 default encoding and have an encoding magic tag.Then when the encoding is force-changed (click on UFT-8 in status line) via "Reopen with Encoding" and later selection-right-click "Stage selected ranges" is done (partial git add-ing) UTF-8 is somehow used always while feeding things to git - even when the right encoding is used otherwise (for file display, save etc.) . This causes all lines with beyond ASCII chars to be messed into the git staging area and so on ....
The same problem exists for other file types like Ruby which use a similar coding tag / magic comment (
coding[:=]\s*([-\w.]+
) in first 2 lines ). Note that this kind of encoding defintion in text / script files is used rather universally - comparable to the XML encoding tag.(Using the Python extension does not improve that. Anyway this issue is too basic and belongs to the editor core)
Hints for implementation:
Does this issue occur when all extensions are disabled?: Yes
The text was updated successfully, but these errors were encountered: