error, when open env file. contained non-ascii string
kitrio opened this issue · comments
[v] Initially raised as discussion
How to use other encoding of env file that is different from os encoding? #2006 - gbk codec error. GBK is chinese character encoding
my env file contained non-ascii comment (wrote korean).
my code
config = Config(".env")
Error message:
File "C:\proj\fastapi-table\venv\lib\site-packages\starlette\config.py", line 63, in init
self.file_values = self._read_file(env_file)
File "C:\proj\fastapi-table\venv\lib\site-packages\starlette\config.py", line 122, in _read_file
for line in input_file.readlines():
UnicodeDecodeError: 'cp949' codec can't decode byte 0xed in position 272: illegal multibyte sequence
cp949 codec is korean encoding in Windows OS
https://github.com/encode/starlette/blob/master/starlette/config.py
config.py _read_file function
line 121 with open(file_name) as input_file:
The Open file option should be modified to UTF-8 encoding.
Important
- We're using Polar.sh so you can upvote and help fund this issue.
- We receive the funding once the issue is completed & confirmed by you.
- Thank you in advance for helping prioritize & fund our backlog.
Please create a discussion first, and format your example.