Skip to content
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

Implicit US-ASCII encoding somewhere #1

Open
chrysn opened this issue Feb 3, 2022 · 1 comment
Open

Implicit US-ASCII encoding somewhere #1

chrysn opened this issue Feb 3, 2022 · 1 comment

Comments

@chrysn
Copy link

chrysn commented Feb 3, 2022

(Proposed resolution at the end, full story for reference)

On my system I get errors like this:

2022-02-03 16:14:01 +0100 Unexpected error while processing request: invalid byte sequence in US-ASCII
        /home/chrysn/.gem/ruby/2.7.0/gems/rack-livereload-0.3.17/lib/rack/livereload/body_processor.rb:78:in `gsub!'
        /home/chrysn/.gem/ruby/2.7.0/gems/rack-livereload-0.3.17/lib/rack/livereload/body_processor.rb:78:in `block in process!'
        /home/chrysn/.gem/ruby/2.7.0/gems/rack-livereload-0.3.17/lib/rack/livereload/body_processor.rb:76:in `each'
        /home/chrysn/.gem/ruby/2.7.0/gems/rack-livereload-0.3.17/lib/rack/livereload/body_processor.rb:76:in `process!'
        /home/chrysn/.gem/ruby/2.7.0/gems/rack-livereload-0.3.17/lib/rack/livereload.rb:28:in `_call'
        /home/chrysn/.gem/ruby/2.7.0/gems/rack-livereload-0.3.17/lib/rack/livereload.rb:14:in `call'
        /home/chrysn/.gem/ruby/2.7.0/gems/thin-1.8.1/lib/thin/connection.rb:86:in `block in pre_process'
        /home/chrysn/.gem/ruby/2.7.0/gems/thin-1.8.1/lib/thin/connection.rb:84:in `catch'
        /home/chrysn/.gem/ruby/2.7.0/gems/thin-1.8.1/lib/thin/connection.rb:84:in `pre_process'
        /home/chrysn/.gem/ruby/2.7.0/gems/thin-1.8.1/lib/thin/connection.rb:53:in `process'
        /home/chrysn/.gem/ruby/2.7.0/gems/thin-1.8.1/lib/thin/connection.rb:39:in `receive_data'
        /home/chrysn/.gem/ruby/2.7.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:195:in `run_machine'
        /home/chrysn/.gem/ruby/2.7.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:195:in `run'
        /home/chrysn/.gem/ruby/2.7.0/gems/thin-1.8.1/lib/thin/backends/base.rb:75:in `start'
        /home/chrysn/.gem/ruby/2.7.0/gems/thin-1.8.1/lib/thin/server.rb:162:in `start'
        /home/chrysn/.gem/ruby/2.7.0/gems/rack-2.2.3/lib/rack/handler/thin.rb:22:in `run'
        /home/chrysn/.gem/ruby/2.7.0/gems/rack-2.2.3/lib/rack/server.rb:327:in `start'
        /home/chrysn/.gem/ruby/2.7.0/gems/rack-2.2.3/lib/rack/server.rb:168:in `start'
        /home/chrysn/.gem/ruby/2.7.0/gems/rack-2.2.3/bin/rackup:5:in `<top (required)>'
        /home/chrysn/.gem/ruby/2.7.0/bin/rackup:25:in `load'
        /home/chrysn/.gem/ruby/2.7.0/bin/rackup:25:in `<main>'

and plain Internal Server Error results in the browser.

As a workaround, I start with RUBYOPT="-KU -E utf-8:utf-8" kdwatch or LC_ALL="en_GB.UTF-8" kdwatch or LC_ALL="C.UTF8: kdwatch, which makes things work better. (Setting LC_ALL to en_US.UTF-8 was insufficient, probably because that locale is not built on my system).

I think that my work environment is all set up for UTF-8 (which, really, all system should have been for ages):

$ env |grep LC\\\|LANG
LANG=en_GB.UTF-8
LANGUAGE=en_GB:en

Operating system is Debian GNU/Linux sid, in a setup that only builds the en_GB.UTF-8 (and a few selected other) locales.


I think that this is related to the ENV["LANG"]="en_US.utf-8" workaround on top of bin/kdwatch -- this sets the default to some (on my system), which I can override by setting LC_ALL.

Quite possibly, the workaround has become obsolete anyway; if it has not, C.UTF-8 might be a suitable replacement (as it should be available no matter which locales are built).

@cabo
Copy link
Owner

cabo commented Feb 3, 2022

It seems C.UTF-8 is a recent invention. It is certainly not universal:

https://unix.stackexchange.com/questions/597962/how-widespread-is-the-c-utf-8-locale

What is the best way to check whether a locale is implemented? I could cycle through a few en_XX.UTF-8 at the start.

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

No branches or pull requests

2 participants