[英]Keeping foreign or special characters in a CSV file
I am trying to save an excel document with slovakian translations in it as a .CSV file. 我正在尝试将带有斯洛伐克语翻译的Excel文档另存为.CSV文件。 and it contains things like this:
它包含以下内容:
"Svoj chybný komponent si môžete nechať opraviť v 3 jednoduchých krokoch:" “ Svojchybnýkomponent simôžetenechaťopraviťv 3jednoduchýchkrokoch:”
the foreign characters like ý, ô, ž, ť etc etc are all being replaced with question marks when I save it as a CSV file. 当我将另存为CSV文件时,诸如ý,ô,ž,ť等外来字符都将替换为问号。 I need the CSV file so I can use PHP to upload the contents to a database
我需要CSV文件,因此可以使用PHP将内容上传到数据库
does anybody know how I can stop this from happening? 有人知道我能阻止这种情况发生吗?
The special charactors are only dropped when you save directly from .xlsx
to CSV
. 仅当直接从
.xlsx
保存到CSV
时,特殊字符才会被删除。 If you save the file to the old .xls
filetype first and then convert that file to CSV
, it should work. 如果先将文件保存为旧的
.xls
文件类型,然后将该文件转换为CSV
,则该文件应该可以使用。
It's important to know that Excel has major bugs and shortcomings when handling CSV files containing non-ascii characters. 重要的是要知道Excel在处理包含非ASCII字符的CSV文件时存在主要的错误和缺点。 There are a number of questions here on SO that discuss it, but the short answer is that it's very very difficult to get right.
SO上有很多问题对此进行了讨论,但是简短的答案是,很难正确地做到这一点。 I suggest avoiding CSV format if possible.
我建议尽可能避免使用CSV格式。
Instead, you may be able to read the Excel file directly in PHP using a third-party library; 相反,您可以使用第三方库直接在PHP中读取Excel文件。 there are several libs available that can do this.
有几个可用的库可以做到这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.