google / ci_edit

A terminal text editor with mouse support and ctrl+Q to quit.
Apache License 2.0
223 stars 54 forks source link

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 0: invalid continuation byte #203

Closed sauravchirania closed 5 years ago

sauravchirania commented 5 years ago

I do not know much about character encoding, and that's perhaps why I can't give out much details, but typing the characters ˆø several times in continuation exits the program with the following error-

Super sorry, something went very wrong.
Please create a New Issue and paste this info there.

Traceback (most recent call last):
  File "/opt/ci_edit/app/ci_program.py", line 524, in wrapped_ci
    prg.run()
  File "/opt/ci_edit/app/ci_program.py", line 461, in run
    self.commandLoop()
  File "/opt/ci_edit/app/ci_program.py", line 245, in commandLoop
    u = bytes_to_unicode((ch, b))
  File "/opt/ci_edit/app/ci_program.py", line 29, in bytes_to_unicode
    return bytes(values).decode("utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 0: invalid continuation byte

System details-

Screenshot 2019-07-10 at 4 03 04 PM

Terminal details-

Screenshot 2019-07-10 at 4 03 50 PM

Also, is this error, in any way, related to #133?

dschuyler commented 5 years ago

Thanks for the report!

I'm using the same Mac OS. My iTerm2 is slightly older: 3.2.7.

I can type ø by pressing Alt+o, but if I try to hold ctrl with that I get the open file dialog (it sees it as ctrl+o, without the Alt). So I'm having a little trouble typing ^ø (err, I'm assuming that ^ in this context means to hold the control key, is that correct?).

If I understand correctly, some European keyboards have a dedicated ø key (which keyboard layout would help me reproduce/see the problem)?

sauravchirania commented 5 years ago

I'm using the same Mac OS. My iTerm2 is slightly older: 3.2.7.

I was able to reproduce this on the default terminal that comes with mac too.

I can type ø by pressing Alt+o, but if I try to hold ctrl with that I get the open file dialog (it sees it as ctrl+o, without the Alt). So I'm having a little trouble typing ^ø (err, I'm assuming that ^ in this context means to hold the control key, is that correct?).

^ did not mean holding the control key. I type the ^ character by holding the (option/alt) key together with i key. I type the ø character by holding the (option/alt) key together with o key.

If I understand correctly, some European keyboards have a dedicated ø key (which keyboard layout would help me reproduce/see the problem)?

The keyboard layout I'm using is U. S. International - PC (I found this out using system preferences -> keyboard -> input sources). The keyboard looks like this - https://support.apple.com/library/content/dam/edam/applecare/images/en_US/keyboards/english_notebook.png

bug_recording

dschuyler commented 5 years ago

^ did not mean holding the control key. I type the ^ character by holding the (option/alt) key together with i key. I type the ø character by holding the (option/alt) key together with o key.

Thanks! That was the piece I was missing. I can see the crash now, I've started on a fix.

As a temporary workaround, you cold pass --singleThread to we. E.g. we --singleThread <some_file>. That will make ci_edit not as quick (using multiple threads makes ci_edit snappier). I hope to have a fix soon.

dschuyler commented 5 years ago

Thanks again,

I know that filing a bug takes some time/effort. This was an issue I didn't know about and was it is important to address it. If something fails in the future, please feel welcome to let me know.

A fix has been submitted. Please try again without --singleThread.

sauravchirania commented 5 years ago

Thanks for the fix. I like this project a lot. Whenever I get a new operating system, I test ci_edit.

It's my dream that before I graduate, I'll make some meaningful code contribution to the project and will try to get it installed in at least a few PCs of laboratories at my university so that it may get some visibility there as a beginner-friendly alternative to vim.