Pistos / diakonos

Diakonos is a console text editor for the masses.
https://git.sr.ht/~pistos/diakonos
Other
137 stars 11 forks source link

ArgumentError: invalid byte sequence in UTF-8 #25

Closed PacoCables closed 11 years ago

PacoCables commented 12 years ago

Probable Causes:


If you can reproduce this error, please report it at

https://github.com/Pistos/diakonos/issues !

/usr/lib/ruby/1.9.1/diakonos/core-ext/string.rb:14:in sub!' /usr/lib/ruby/1.9.1/diakonos/core-ext/string.rb:14:inexpand_tabs' /usr/lib/ruby/1.9.1/diakonos/buffer/display.rb:307:in block in display' /usr/lib/ruby/1.9.1/diakonos/buffer/display.rb:295:ineach' /usr/lib/ruby/1.9.1/diakonos/buffer/display.rb:295:in each_with_index' /usr/lib/ruby/1.9.1/diakonos/buffer/display.rb:295:indisplay' /usr/lib/ruby/1.9.1/diakonos/display.rb:283:in `block in display_buffer'

Pistos commented 12 years ago

Could you describe the steps to reproduce this? It's actually a fairly common error.

marcovansteen commented 11 years ago

I experienced this today for the first time. Example log:

root@lacantinajazz:/home/www/repie# diakonos index.php /usr/lib/ruby/1.9.1/diakonos/core-ext/string.rb:50:in index': invalid byte sequence in UTF-8 (ArgumentError) from /usr/lib/ruby/1.9.1/diakonos/core-ext/string.rb:50:inblock in group_index' from /usr/lib/ruby/1.9.1/diakonos/core-ext/string.rb:49:in loop' from /usr/lib/ruby/1.9.1/diakonos/core-ext/string.rb:49:ingroup_index' from /usr/lib/ruby/1.9.1/diakonos/buffer/searching.rb:425:in block (2 levels) in seek' from /usr/lib/ruby/1.9.1/diakonos/buffer/searching.rb:424:ineach' from /usr/lib/ruby/1.9.1/diakonos/buffer/searching.rb:424:in block in seek' from /usr/lib/ruby/1.9.1/diakonos/buffer/searching.rb:410:incatch' from /usr/lib/ruby/1.9.1/diakonos/buffer/searching.rb:410:in seek' from /usr/lib/ruby/1.9.1/diakonos/functions/search.rb:160:inseek' from /usr/lib/ruby/1.9.1/diakonos.rb:383:in start' from /usr/bin/diakonos:6:in

' root@lacantinajazz:/home/www/repie# ls -l index.php -rwxr-xr-x 1 root www-data 3392 Jul 22 00:16 index.php root@lacantinajazz:/home/www/repie#

FWIW: I noticed that diakonos crashes if I type special symbols like the ° symbol. Errors:

/usr/lib/ruby/1.9.1/diakonos/buffer.rb:201:in +': can't convert Fixnum into String (TypeError) from /usr/lib/ruby/1.9.1/diakonos/buffer.rb:201:ininsert_string' from /usr/lib/ruby/1.9.1/diakonos/keying.rb:412:in type_character' from /usr/lib/ruby/1.9.1/diakonos/keying.rb:286:inprocess_keystroke' from /usr/lib/ruby/1.9.1/diakonos.rb:391:in start' from /usr/bin/diakonos:6:in

' root@lacantinajazz:/home/www/repie#

Pistos commented 11 years ago

@marcovansteen : I'll need a copy of whatever file(s) you're working with that trigger these problems. You could use gist.github.com or something to give them to me.

I was able to paste ° into a new file just now, with no crash.

marcovansteen commented 11 years ago

Hi Pistos, Attached is the text file at which diakonos crashes. I apologize in advance for any bad practices in the code that's in it ;-) Best regards, Marco

PS: my compliments for all the good work that's put in diakonos! it's my number 1 linux command line editor.

2013/8/1 Pistos notifications@github.com

@marcovansteen https://github.com/marcovansteen : I'll need a copy of whatever file(s) you're working with that trigger these problems. You could use gist.github.com or something to give them to me.

I was able to paste ° into a new file just now, with no crash.

— Reply to this email directly or view it on GitHubhttps://github.com/Pistos/diakonos/issues/25#issuecomment-21947691 .

Pistos commented 11 years ago

Thank you for the compliment.

Now, as for your file, it did not get sent to github when you replied by email. You'll have to furnish it by going to something like https://gist.github.com/ . Though, if you can put it up on a website somewhere, that would be better, because gist might remove some of the parts of the text that are causing the problem.

marcovansteen commented 11 years ago

Hi Pistos,

I attached the file tst.php to my previous email. Did you miss the attachment? I didn't use gist.github.com because I expect that it does not transfer all details like end-of-line delimiters. Instead the file url is here http://www.repie.nl/tst.txt . For clarity i renamed it from tst.php to tst.txt . With the .txt extension the same problems occur.

Hope this helps.

Best regards, Marco

2013/8/2 Pistos notifications@github.com

Thank you for the compliment.

Now, as for your file, it did not get sent to github when you replied by email. You'll have to furnish it by going to something like https://gist.github.com/ .

— Reply to this email directly or view it on GitHubhttps://github.com/Pistos/diakonos/issues/25#issuecomment-22017852 .

Pistos commented 11 years ago

Thank you. I got the file, and I am able to see the error. I will check this out.

Pistos commented 11 years ago

Okay, I've investigated this a bit. I admit, I am not very well-versed in character encodings, but it appears your file is in ISO-8859 encoding. You can determine this with the UNIX utility file. e.g. file tst.txt

I converted your file with iconv:

iconv --from-code=ISO-8859-1 --to-code=UTF-8 tst.txt > tst-utf-8.txt

and then I was able to open the converted file with Diakonos, and it looked the same to me.

I am not willing to make Diakonos support ISO-8859 files at this time, sorry.

marcovansteen commented 11 years ago

Ah OK. Thanks for the help. I will check out why this encoding was used.

cheers!

2013/8/2 Pistos notifications@github.com

Okay, I've investigated this a bit. I admit, I am not very well-versed in character encodings, but it appears your file is in ISO-8859 encoding. You can determine this with the UNIX utility file. e.g. file tst.txt

I converted your file with iconv:

iconv --from-code=ISO-8859-1 --to-code=UTF-8 tst.txt > tst-utf-8.txt

and then I was able to open the converted file with Diakonos, and it looked the same to me.

I am not willing to make Diakonos support ISO-8859 files at this time, sorry.

— Reply to this email directly or view it on GitHubhttps://github.com/Pistos/diakonos/issues/25#issuecomment-22031519 .