Change text encoding of .txt file
I don't know if this works with Farsi: I use Gedit, it gives a fault with wrong encoding, and I can chose what I want to translate to UTF-8, it was just text not lit format, but here is a screenshot! This will save the corrected file using the UTF-8 encoding: Now click the encoding button again and this time select the "Save with Encoding" option, just as below:Īnd in the new menu select the "UTF-8" option: This will fix the gibberish text like this: In the Convert File dialog box, select Encoded Text. Scroll to the General section, and then select the Confirm file format conversion on open check box. This will open another menu which includes a list of different encoding, as shown below. Regarding this, how do I change the encoding of a text file Choose an encoding standard when you open a file Click the File tab. From this menu select the "Reopen with Encoding" option, just like below: One of them is related to the file encoding, as shown below:Ĭlicking this button pops up an overhead menu which includes two items. At the bottom of the window, there are a few buttons. Open the file you want to convert its encoding in VS-Code.
#Change text encoding of .txt file code#
The working solution I found is using the Microsoft Visual Studio Code text editor which is Freeware and available for Linux. Trying either ISO-8859-15 or WINDOWS-1252 for a Persian text was obviously an impasse: these encodings merely do not contain any Persian letter.
Not some (naïve) guesses based on mojibake characters in programs that try (but fail) to read it. or -f) one must specify encoding with which the file is saved (by the program that created it). Original poster is also confused with semantic of text recoding tools (recode, iconv). To convert to any encoding (UTF-8 or otherwise), regardless of the current locale, one can say: iconv -f Windows-1256 Windows_file.txt -t $ This one assumes that the LANG environment variable is set to a UTF-8 locale. (denounced upon original poster’s complaints see comments) iconv -f Windows-1256 Windows_file.txt > UTF8_file.txt So it can be deciphered by command similar to OP tried, but with different charsets. These Windows files with Persian text are encoded in Windows-1256.