How to fix the encoding of a requirements.txt file on macOS?

79 Views Asked by At

I am working under macOS Monterey 12.4 and trying to open my requirements.txt file got by pip3 freeze > requirements.txt command in terminal with TextEdit. That gives me a few lines of hieroglyphs looking so, and further tries to change the encoding through TextEdit settings to any other one bring me no result: the text in file doesn't change at all. I've discovered with file -I requirements.txt that the encoding of my file is utf-16le but it makes no difference to me for the reason named before. What am I doing wrong?

Steps I made were the next:

  1. Create a file with pip3 freeze > requirements.txt
  2. Open the file in TextEdit
  3. Get stuff
  4. Change encoding in TextEdit through Settings > "Opening Files" (under Plain Text Encoding) to any random
  5. See no changes
  6. Get charset=utf-16le with file -I requirements.txt
  7. Repeat steps 4-5 choosing "Unicode (UTF-16LE)" namingly
  8. Still have no positive results

UPD 1 attached hex dump of the file:

00000000: 636f 6e74 6f75 7270 793d 3d31 2e31 2e31  contourpy==1.1.1
00000010: 0a63 7963 6c65 723d 3d30 2e31 322e 310a  .cycler==0.12.1.
00000020: 666f 6e74 746f 6f6c 733d 3d34 2e34 372e  fonttools==4.47.
00000030: 320a 696d 706f 7274 6c69 622d 7265 736f  2.importlib-reso
00000040: 7572 6365 733d 3d36 2e31 2e31 0a6b 6977  urces==6.1.1.kiw
00000050: 6973 6f6c 7665 723d 3d31 2e34 2e35 0a6d  isolver==1.4.5.m
00000060: 6174 706c 6f74 6c69 623d 3d33 2e37 2e34  atplotlib==3.7.4
00000070: 0a6e 756d 7079 3d3d 312e 3234 2e34 0a70  .numpy==1.24.4.p

UPD 2 locale outputs:

LANG="ru_RU.UTF-8"
LC_COLLATE="ru_RU.UTF-8"
LC_CTYPE="ru_RU.UTF-8"
LC_MESSAGES="ru_RU.UTF-8"
LC_MONETARY="ru_RU.UTF-8"
LC_NUMERIC="ru_RU.UTF-8"
LC_TIME="ru_RU.UTF-8"
LC_ALL=

UPD 3 I've discovered that VSCode suddenly displays my requirements.txt in a correct way and got into stuck. How is to deal with the same case next time?

0

There are 0 best solutions below