当前位置:网站首页>Batch modify the txt file code to UTF-8 (notepad++)

Batch modify the txt file code to UTF-8 (notepad++)

2022-07-05 07:37:00 HAGUU

Please like it , thank you ~Thanks*(・ω・)ノ
After two days of practice , Succeed in putting txt File from the ASCI turn UTF-8 And there is no garbled code in the text , The general steps are as follows :

  1. The computer has python( Previously installed ,windows Generally there are )
  2. Notepad++, plug-in unit - Plug-in management - install python script
  3. python script newly build script, Script name customization ( Such as :convertUtf8.py)
    The script code is as follows :
import os;
import sys; 
filePathSrc="C:\\decompile\\" # Path to the folder with files to convert 
for root, dirs, files in os.walk(filePathSrc): 
 for fn in files: if fn[-4:] == '.htm': # Specify type of the files 
        notepad.open(root + "\\" + fn) 
        notepad.runMenuCommand("Encoding", "Convert to UTF-8") notepad.save()
        notepad.close()

Related articles : The source of the above code
4. The first 3 Step by step .py The file in notepad++ open ( Such as :convertUtf8.py)
5. stay notepad++ Execute the script
Related articles : Method of execution
6. The first 5 After executing step plug-in unit -python script-scripts A new action bar is generated under “convertUtf8”
relevant :
. If you want to go from scripts Delete the script under the column , Then open the location where the script is saved , Delete file , restart notepad++ that will do
. If you want to edit this script , Press and hold ctrl And click the operation bar
7. To be transferred txt Put the file in the 3 Under the folder path mentioned in the script
8. Notepad++ Open... In 7 All the encoded documents to be transferred in step
9. Click on : plug-in unit -python script-scripts-convertUtf8
The first 9 After step execution, the file starts from notepad++ Automatically close , Code conversion succeeded .

原网站

版权声明
本文为[HAGUU]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140553012453.html