<转>巧用notepad++ 批量转换ansi 和 utf8

简介: 原方出处:http://stackoverflow.com/questions/7256049/notepad-converting-ansi-encoded-file-to-utf-8   Here some simple steps to convert multiple files via...

原方出处:http://stackoverflow.com/questions/7256049/notepad-converting-ansi-encoded-file-to-utf-8

 

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

  1. Run Notepad++ and then open menu Plugins->Plugin Manager->Show Plugin Manager
  2. Install Python Script. When plugin is installed, restart the application.
  3. Choose menu Plugins->Python Script->New script.
  4. Choose its name, and then past the following code:

convertToUTF8.py

import os;
import sys;
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.save()
            notepad.close()

After all, run the script

 

如果要转化为ANSI 就把插件代码改为下面

import os;
import sys;
filePathSrc="E:\\lua_tymyd\\" # Path to the folder with files to convert
for root, dirs, files in os.walk(filePathSrc):
    for fn in files: 
        if fn[-4:] == '.lua': # Specify type of the files
            notepad.open(root + "\\" + fn)      
            notepad.runMenuCommand("Encoding", "Convert to ANSI")
            notepad.save()
            notepad.close()

 

相关文章
|
2天前
|
存储 SQL 编解码
【YashanDB 知识库】GBK 库,生僻字插入 nvarchar2 字段后乱码问题
在使用 GBK 编码的数据库时,插入包含生僻字的数据会导致编码问题。GBK 编码不支持某些生僻字,导致插入后显示乱码。客户端和服务端编码不一致(如客户端为 UTF-8,服务端为 GBK)会加剧此问题。受影响版本为 23.2.4.14 及之前版本。 **解决方法:** 1. 确保终端和服务端编码一致,建议使用 UTF-8 编码。 2. 使用 yasdb client 库接口,通过 `yacBindParameter` 接口以 UTF-16 编码插入数据。
|
5月前
|
存储 自然语言处理 API
超级好用的C++实用库之字符编码转换
超级好用的C++实用库之字符编码转换
94 2
|
6月前
|
存储 自然语言处理
字符编码问题之Unicode传统字符编码方案中的语言编码冲突如何解决
字符编码问题之Unicode传统字符编码方案中的语言编码冲突如何解决
77 1
|
9月前
|
存储
【VBA代码解决方案】md文档转Word后,全自动转换为标准的Word公式格式
【VBA代码解决方案】md文档转Word后,全自动转换为标准的Word公式格式
226 0
将ansi文本格式以utf-8文本格式进行读取
查阅网上很多博客关于其他文本格式转化成utf-8,会出现中文乱码的情况,自己也遇到了,看到网上很多乱七八糟的博客,都没有什么实质性的解决方案。为此专门写了这篇博客,希望能对你们有帮助。
119 0
|
存储 Windows
“浅入深处“编码历史,字符串编码(ASCII, GBK, ANSI, Unicode, UTF-8编码),为什么记事本默认ANSI编码,Unicode和UTF8有什么区别
“浅入深处“编码历史,字符串编码(ASCII, GBK, ANSI, Unicode, UTF-8编码),为什么记事本默认ANSI编码,Unicode和UTF8有什么区别
172 0
|
存储 开发工具 数据安全/隐私保护
[oeasy]python0132_[专业选修]utf-8_unicode_transformation_format_8_编码方式
[oeasy]python0132_[专业选修]utf-8_unicode_transformation_format_8_编码方式
126 0
[oeasy]python0132_[专业选修]utf-8_unicode_transformation_format_8_编码方式
|
编译器 Shell Linux
VS2019 高级保存设置UTF-8编码-源代码乱码问题
VS2019 高级保存设置UTF-8编码-源代码乱码问题
1355 0
VS2019 高级保存设置UTF-8编码-源代码乱码问题
|
开发工具
新增2款开发工具:base64编码解码,unicode编码解码
最近由于工作需要,制定了一份底层通信协议,为了保证协议顺利传输任意内容,规定数据段必须采用base64编码,来规避其他字符对于协议解析的影响。然后就顺手为本站新增2款开发人员工具。 base64编码解码 体验地址:https://www.opengps.cn/Tools/Base64/Index.aspx unicode编码解码 体验地址:https://www.opengps.cn/Tools/Unicode/Index.aspx 原文地址: https://www.opengps.cn/Blog/View.aspx?id=382 文章的更新编辑依此链接为准。
1321 0
|
Java Android开发 Windows
Ecplise设置全局编码为UTF-8的方法
如果要使插件开发应用能有更好的国际化支持,能够最大程度的支持中文输出,则最好让Java文件使用UTF-8编码。 然而,Eclipse工作空间(workspace)的缺省字符编码是操作系统缺省的编码,简体中文操作系统 (Windows XP、Windows 2000简体中文)的缺省编码是GB18030,Windows7/8/10的缺省编码是GBK,在此工作空间中建立的工程编码是GB18030或者GBK,工程中建立的java文件也是GB18030或者GBK。
1440 0