Skip to content

Commit dbab7df

Browse files
committed
Fix Python UTF-8 encoding issue on the console and Dockerfile
1 parent 9d8a44c commit dbab7df

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ WORKDIR /app
3030

3131
# Update PATH environment variable + set Python buffer to make Docker print every message instantly.
3232
ENV PATH=/root/.local:$PATH \
33-
PYTHONUNBUFFERED=1
33+
PYTHONUNBUFFERED=1\
34+
PYTHONIOENCODING=utf-8\
35+
PYTHONLEGACYWINDOWSSTDIO=utf-8
3436

3537
# copy only the dependencies installation from the 1st stage image
3638
COPY --from=builder /root/.local /root/.local

mrn_console_rtds.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535

3636
_news_envelopes = []
3737

38+
# Config the encoding for the console
39+
sys.stdin.reconfigure(encoding='utf-8')
40+
sys.stdout.reconfigure(encoding='utf-8')
41+
3842
''' MRN Process Code '''
3943

4044

mrn_console_rto_v2.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
mrn_item = 'MRN_STORY'
4646
_news_envelopes = []
4747

48+
# Config the encoding for the console
49+
sys.stdin.reconfigure(encoding='utf-8')
50+
sys.stdout.reconfigure(encoding='utf-8')
51+
4852

4953

5054
class WebSocketSession:

0 commit comments

Comments
 (0)