-
Notifications
You must be signed in to change notification settings - Fork 38
Fix encoding in forms #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Can you please explain to me what this pull request changes specifically and why you feel the changes are necessary. |
| self._writeline(cmd) | ||
| self._writeline(str(len(args))) | ||
| for arg in args: | ||
| arg = str(arg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function cannot handle unicode strings. Try the following:
str(u"canción")
| if type(arg) == unicode: | ||
| arg = arg.encode("utf-8") | ||
| self._writeline(str(len(arg))) | ||
| self._sock.sendall(arg.encode("utf-8")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only unicode strings need to be encoded as utf-8 to be sent as bytes to webkit server
|
|
||
| def _writeline(self, line): | ||
| """ Writes a line to the underlying socket. """ | ||
| self._sock.sendall(line.encode("utf-8") + b"\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a problem if you encode twice. Try the following:
u"canción".encode('utf-8').encode('utf-8')
| if type(line) == unicode: | ||
| line = line.encode("utf-8") | ||
| """ Writes a line to the underlying socket. """ | ||
| self._sock.sendall(line.encode("utf-8") + b"\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Encoding twice can create errors:
u"canción".encode('utf-8').encode('utf-8')
|
I was working with some forms. I had to add some unicode data like "Nuñez" but the following error showed up: |
Fix #27