getting this error : incompatible encodings: UTF-8 and ASCII-8BIT #978
Replies: 1 comment
|
The locale and
values = {
post_title: post_title,
cover_url: post_cover_shot[:url],
asset_host: GoshPosh::Settings.asset_host,
listing_url: construct_redirect_url("/listing/#{post_id}", :email, fvv_id, locals)
}
values.each do |name, value|
s = value.to_s
warn "#{name}: encoding=#{s.encoding}, valid=#{s.valid_encoding?}, bytes=#{s.bytesize}"
endRun that in the same worker/render path. Testing values in a console is not sufficient if the queue deserializer or database adapter creates binary strings only in the worker. Once the offending boundary is known, normalize there. If its bytes are known to already be UTF-8 but merely mislabeled: s = value.to_s.dup
s.force_encoding(Encoding::UTF_8)
raise "invalid UTF-8" unless s.valid_encoding?If the source has a real known encoding, transcode it instead: s = value.to_s.encode(Encoding::UTF_8, source_encoding)Do not blindly call A minimal way to isolate the exact expression is to assign each interpolation to a local immediately before rendering and append them one at a time to a UTF-8 buffer: out = String.new(encoding: Encoding::UTF_8)
values.each { |name, value| out << value.to_s; warn "OK: #{name}" }The first value that raises is the boundary to fix. Also test the body independently: rendered_body = body.render(scope, data: data)
warn "body=#{rendered_body.encoding}, valid=#{rendered_body.valid_encoding?}"Then pass So I would keep |
Uh oh!
There was an error while loading. Please reload this page.
Using : Jruby-9.2.8.0 , Tilt:2.6.1 , slim (5.2.1),temple (0.10.3)
full error:
competing_offer.slim:
data is all 'UTF-8' (#{post_title})
host encoding setup:
goshposh@ten-qw:/goshposh/server$ jruby -e 'p [Encoding.default_external, ENV["LC_ALL"], ENV["LC_CTYPE"], ENV["LANG"]]' [#<Encoding:UTF-8>, "en_US.UTF-8", nil, "en_US.UTF-8"]Getting this error after upgrading slim (1.2.2) to slim (5.2.1),temple (0.4.0) to temple (0.10.3),tilt (1.3.7) to tilt (2.6.1)
All reactions