send_data(ruby-on-rails)文件名中的编码问题

时间:2019-04-26 13:15:43

标签: ruby-on-rails nginx character-encoding ubuntu-16.04 filenames

我有一个服务器:
ubuntu 16.04
nginix
乘客

我尝试使用send_data的方式发送文件,文件名是Cyrillic,但是当我收到(由于下载文件)而收到的文件名,则使用了错误的编码。
示例:
在服务器上:Сводный_отчет_по_СПК_имени_Куйбышева_за_25.04.2019г.xlsx
下载时:ÐÐд。。。。。。。。。。。。¼¼¼。 Ð_ени½½Ð°_за_25.04.2019г.xlsx

我的功能

send_data package.to_stream.read, type: 'application/xlsx', filename: "Сводный_отчет_по_#{name}_за_#{to_date}.xlsx"

1 个答案:

答案 0 :(得分:0)

尝试指定编码

n <- nrow(mtcars)

for (i in 1:n){
  cat("\n mtcars currently has",nrow(mtcars),"rows;","accessing row",i)
  if (mtcars$cyl[i] == 4){
    mtcars <- mtcars[-i,]
  }
}

> mtcars currently has 32 rows; accessing row 1
 mtcars currently has 32 rows; accessing row 2
 mtcars currently has 32 rows; accessing row 3
 mtcars currently has 31 rows; accessing row 4
 mtcars currently has 31 rows; accessing row 5
 mtcars currently has 31 rows; accessing row 6
 mtcars currently has 31 rows; accessing row 7
 mtcars currently has 30 rows; accessing row 8
 mtcars currently has 30 rows; accessing row 9
 mtcars currently has 30 rows; accessing row 10
 mtcars currently has 30 rows; accessing row 11
 mtcars currently has 30 rows; accessing row 12
 mtcars currently has 30 rows; accessing row 13
 mtcars currently has 30 rows; accessing row 14
 mtcars currently has 30 rows; accessing row 15
 mtcars currently has 30 rows; accessing row 16
 mtcars currently has 29 rows; accessing row 17
 mtcars currently has 28 rows; accessing row 18
 mtcars currently has 28 rows; accessing row 19
 mtcars currently has 28 rows; accessing row 20
 mtcars currently has 28 rows; accessing row 21
 mtcars currently has 28 rows; accessing row 22
 mtcars currently has 27 rows; accessing row 23
 mtcars currently has 26 rows; accessing row 24
 mtcars currently has 26 rows; accessing row 25
 mtcars currently has 26 rows; accessing row 26
 mtcars currently has 25 rows; accessing row 27
Error in if (mtcars$cyl[i] == 4) { : 
  missing value where TRUE/FALSE needed