Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

getting encoding error KOREAN #2

Open
myrayearth opened this issue May 28, 2019 · 3 comments
Open

getting encoding error KOREAN #2

myrayearth opened this issue May 28, 2019 · 3 comments

Comments

@myrayearth
Copy link

myrayearth commented May 28, 2019

Hello,
I'm getting encoding error:
i use Language KOREAN and test JAPANESE language too.
i try -e PYTHONIOENCODING=utf-8 and euc-kr , but can't work it.
can you fix it?

192.168.0.200 - - [28/May/2019 15:35:07] "GET /command?message=turn%20off%20light HTTP/1.1" 200 -,
[2019-05-28 15:35:18,202] ERROR in app: Exception on /command [GET],
Traceback (most recent call last):,
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1832, in full_dispatch_request,
rv = self.dispatch_request(),
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1818, in dispatch_request,
return self.view_functionsrule.endpoint,
File "/usr/local/lib/python3.5/dist-packages/flask_restful/init.py", line 458, in wrapper,
resp = resource(*args, **kwargs),
File "/usr/local/lib/python3.5/dist-packages/flask/views.py", line 88, in view,
return self.dispatch_request(*args, **kwargs),
File "/usr/local/lib/python3.5/dist-packages/flask_restful/init.py", line 573, in dispatch_request,
resp = meth(*args, **kwargs),
File "/gawebserver.py", line 169, in get,
assistant.send_text_query(message),
File "/usr/local/lib/python3.5/dist-packages/google/assistant/library/assistant.py", line 215, in send_text_query,
self._lib.assistant_send_text_query(self._inst, query.encode('ASCII')),
UnicodeEncodeError: 'ascii' codec can't encode character '\ubd88' in position 0: ordinal not in range(128),
192.168.0.200 - - [28/May/2019 15:35:18] "GET /command?message=불%20꺼 HTTP/1.1" 500 -,

@jsj0318
Copy link

jsj0318 commented Jul 19, 2019

On line 215 of the assistant.py file
self._lib.assistant_send_text_query (self._inst, query.encode ('ASCII')) to
self._lib.assistant_send_text_query (self._inst, query.encode ('UTF-8'))
change 'ASCII' to 'UTF-8',
you can make Korean commands without any problem.

@myrayearth
Copy link
Author

On line 215 of the assistant.py file
self._lib.assistant_send_text_query (self._inst, query.encode ('ASCII')) to
self._lib.assistant_send_text_query (self._inst, query.encode ('UTF-8'))
change 'ASCII' to 'UTF-8',
you can make Korean commands without any problem.

thank you so much!
it's work now!

@almostserious
Copy link

In case somebody else is wondering about this. If you want to edit the assistant.py directly in the docker you can do that via:

sudo docker container exec -it gawebserver nano /usr/local/lib/python3.5/dist-packages/google/assistant/library/assistant.py

You might need to install nano beforehand. You can do that via:
sudo docker container exec -it gawebserver apt-get update &
sudo docker container exec -it gawebserver apt-get install nano
Not sure if this survives redeployment... but a docker restart seems fine for this :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants