notepad html编码转换,使用notepad++批量转换文件编码

该博客介绍了如何通过安装和使用Notepad++的PythonScript插件,来批量将指定文件夹内的.xml文件转换为UTF-8编码,避免特殊字符乱码问题。操作步骤包括安装PythonScript插件、编写并运行脚本来实现自动化转换和保存。
摘要由CSDN通过智能技术生成

Here some simple steps to convert multiple files via Notepad++ without messing up with special characters (for ex. diacritical marks).

Run Notepad++ and then open menu Plugins->Plugin Manager->Show Plugin Manager

Install Python Script. When plugin is installed, restart the application.

Choose menu Plugins->Python Script->New script.

Choose its name, and then past the following code:

convertToUTF8.py

import os

import sys

from Npp import notepad # import it first!

filePathSrc="C:\\Users\\" # Path to the folder with files to convert

for root, dirs, files in os.walk(filePathSrc):

for fn in files:

if fn[-4:] == '.xml': # Specify type of the files

notepad.open(root + "\\" + fn)

notepad.runMenuCommand("Encoding", "Convert to UTF-8")

notepad.saveAs(os.join.path(fn[:-4], '_utf8.xml')) # if you try to save/replace the file, an annoying confirmation window would popup.

notepad.close()

After all, run the script

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值