简体   繁体   中英

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. and it contains things like this:

"Svoj chybný komponent si môžete nechať opraviť v 3 jednoduchých krokoch:"

the foreign characters like ý, ô, ž, ť etc etc are all being replaced with question marks when I save it as a CSV file. I need the CSV file so I can use PHP to upload the contents to a database

does anybody know how I can stop this from happening?

The special charactors are only dropped when you save directly from .xlsx to CSV . If you save the file to the old .xls filetype first and then convert that file to CSV , it should work.

It's important to know that Excel has major bugs and shortcomings when handling CSV files containing non-ascii characters. 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. I suggest avoiding CSV format if possible.

Instead, you may be able to read the Excel file directly in PHP using a third-party library; there are several libs available that can do this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM