Question Marks (?) instead of Persian Characters in .txt File
Question by Guest | 2019-06-12 at 07:55
I exported content of a 2-column bilingual (English-Persian) Excel 2010 file to a tab-separated text file. But the content of the second column in the .txt file instead of being in Persian just shows a number of question marks (?) for the Persian words. How can I fix this?
Thanks a million in advance for your help.
Related Topics
MySQL: Line Breaks in MySQL
Tip | 0 Comments
I love you - In all Languages
Info | 0 Comments
Rename File to its Folder Name
Tutorial | 0 Comments
Rewrite Text Files with a fixed Line Length
Tutorial | 0 Comments
PHP: Check Strings with Ctype-Functions for Character Classes
Article | 0 Comments
PHP: Remove arbitrary Characters at the Beginning and the End of a String
Tutorial | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
That can happen, if the encoding of the text file is not capable of storing the characters. Then the characters that can not be stored are stored as ?. Probably, you are saving your text file in ANSI format, which can only differ between 256 characters. That are for example the characters from A to Z and a to z but not Persian characters.
What you need is a Unicode format such as UTF-8 which is capable of storing all characters. Depending on your Excel version, you can find the corresponding settings in the storage dialog left to the save-button. In some Excel versions, you can set up the encoding there directly, in other Excel versions, you have to click on "Tools" > "Web Options". I recommend using the format Unicode (UTF-8).
If you want more background information about that, you can get information about the ANSI format or other Unicode formats.
2019-06-12 at 15:05
Thank you dear Stefan,
You're right. I made the changes in my Excel file as you said. But, when I save the Excel file as a tab-separated text file, the resulting .txt file is still in ANSI format with the problem of question marks instead of Persian character. How can I change the .txt file to a Unicode Text (.txt) file?
Thanks a million in advance for your help.
2019-06-12 at 15:58
Have you changed the encoding in the save-dialog of Excel? The default is a Windows ANSI encoding here and if Excel is not saving your decision, you have to change the settings every time you want to save your CSV.
If you want to change the encoding of an existing file, you can use the program TextEncoder. However, if there are one time question marks in the file, the information about the original characters is lost, because there are only the same questions marks left for each original character and cannot reconstruct what character a question mark had been before.
2019-06-12 at 16:04
Hi again dear Stefan,
In the Save As dialog window here there is no any option for choosing an encoding whatever. I set the “File > Options > Advanced > General > Web Options > Encoding > Save this document as:” to “Unicod (UTF-8)”. Then, Save As > Save as type: Unicode Text (*.txt) and the result is ideal.
The question now is that how I can make Excel always automatically save in Unicode without needing me to go through the steps said above.
Thank you again for your help.
2019-06-13 at 06:36
Unfortunately, Excel does not have an option to set up a default character encoding there.
I don't know why the developers of Excel could forget that.
2019-06-13 at 20:17