Error: incompatible Character encodings: UTF-8 and ASCII-8BIT

Asked

Viewed 884 times

3

Incompatible Character encodings: UTF-8 and ASCII-8BIT.

{"utf8"=>"✓",
"authenticity_token"=>"3cl0R8ghLDvPMGkh0I+LCrzQjmyu1donLE9y58rIT1k=",
"post"=>{"title"=>"Somos apaixonados por música!",
"caption"=>"Estamos entrando na fase final da construção do estúdio. Mau podemos esperar para iniciar os trabalhos dos grandes artistas que nos esperam.",
"photo"=>#<ActionDispatch::Http::UploadedFile:0x00000103339718 @original_filename="Captura de Tela 2014-05-30 a\xCC\x80s 11.45.37 (2).png",
@content_type="image/png",
@headers="Content-Disposition: form-data; name=\"post[photo]\"; filename=\"Captura de Tela 2014-05-30 a\xCC\x80s 11.45.37 (2).png\"\r\nContent-Type: image/png\r\n",
@tempfile=#<File:/var/folders/qa/qas8gqrFHKeYuO3C3gst+E+++TI/-Tmp-/RackMultipart20140604-1488-amcll7>>,
"style_photo"=>"1"},
"commit"=>"Cadastrar Notícia"}

PROBLEM:

The problem is in the name of the file I’m trying to climb, it contains an accent(Screenshot 2014-05-30 at 11.45.37 (2). png) and so it’s generating this mistake.

Is there any way to fix this?

  • Could you include your config/enviroment.Rb file? And make sure your application.Rb contains: config.encoding = "utf-8"

  • I’ve laid them both with utf8

1 answer

2

Try to do the following:

file_data = params[:import_file].tempfile.read.force_encoding("ISO-8859-1")
utf8_file_data = file_data.encode(utf8_format)

Withdrawn of this question by Stack-EN

Browser other questions tagged

You are not signed in. Login or sign up in order to post.