N
N
Nitrino2014-05-11 23:08:07
Ruby on Rails
Nitrino, 2014-05-11 23:08:07

Encoding xls file when requesting rails?

There is an xls file generation, it works correctly, when accessed from the browser, the file is downloaded and displayed in excel with the correct encoding, so if I make a request through the HTTP client, I also get the correct Russian text. I need to attach this file to a letter, I make a request using ActionDispatch::Integration::RequestHelpers
session.get('issues#index', {format: :xls,})
and as a result, question marks instead of Russian text in session.response.body. and

encode("UTF-8", :invalid => :replace, :undef => :replace, :replace => "")
doesn't help, it just doesn't change anything.
What could be the reason? Or can someone tell me another way to make an attachment in which I will not encounter such a problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nitrino, 2014-05-12
@Nitrino

I found a solution myself, in the request you need to specify Accept-Language: ru-RU
final request:

session.get('issues#index', {format: :xls}, {'HTTP_ACCEPT_LANGUAGE' => 'ru-RU'})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question