Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 导出带有变音符号的CSV会导致输出中出现奇怪的字符_Linux_Windows_Scala_Csv - Fatal编程技术网

Linux 导出带有变音符号的CSV会导致输出中出现奇怪的字符

Linux 导出带有变音符号的CSV会导致输出中出现奇怪的字符,linux,windows,scala,csv,Linux,Windows,Scala,Csv,我在Scala/Spray中导出csv,它在我的Windows机器上运行良好,但在Linux机器上失败 来自两个操作系统的响应是相同的: Access-Control-Allow-Credentials:true Access-Control-Allow-Headers:X-Requested-With, Cache-Control, Pragma, Origin, Authorization, Content-Type, Auth-Token Access-Control-Allow-Meth

我在Scala/Spray中导出csv,它在我的Windows机器上运行良好,但在Linux机器上失败

来自两个操作系统的响应是相同的:

Access-Control-Allow-Credentials:true
Access-Control-Allow-Headers:X-Requested-With, Cache-Control, Pragma, Origin, Authorization, Content-Type, Auth-Token
Access-Control-Allow-Methods:GET, POST, DELETE, OPTIONS, PUT
Access-Control-Allow-Origin:*
Access-Control-Expose-Headers:Auth-Token
Content-Disposition:attachment; filename=Enter report title.csv
Content-Length:229
Content-Type:text/csv; charset=ISO-8859-1
Date:Fri, 07 Feb 2014 22:17:40 GMT
Server:spray-can/1.2.0
我想知道为什么操作系统可以带来不同

在部署jar后从linux导出时,用奇怪的字符替换变音符号

比如这家马基亚托咖啡馆 从Windows导出时可以,但看起来像Cafémacchiato
从Linux导出时。

请永远不要将Excel用于面向文本的文件。它把事情搞砸了。使用vim或Notepad++之类的编辑器,您可以检查字节并实际查看您的内容是否正确。

要帮助Excel识别字符编码,您可以在文件开头添加一个。例如:

def prepareBomOutputStream(outputFile: String) = {
  val os = new FileOutputStream(outputFile)
  os.write(239)
  os.write(187)
  os.write(191)
  os
}
您还可以检查在这两种情况下是否得到完全相同的编码,而不是编码的子集。例如,在Windows上,您可能会得到ISO-8859-15。您最有可能在CSV导出代码/库中显式设置编码。要在Linux上检查编码,可以使用:

$ file -ib /tmp/test.csv 
text/plain; charset=utf-8

甚至像hexdump这样的东西。

如何在两个操作系统中查看文件?@AlekseyIzmailov我从本地环境导出,并在Win 7-Excel中查看,从Linux环境上托管的网站导出时也是如此。