如何在Notepad++中转换未使用的Unicode(例如\u0432\u0441\u0435)到UTF-8 chars () ?

时间:2022-09-17 20:21:10

I have .properties files with a bunch of unicode escaped characters. I want to convert it to the correct chars display.

我有.properties文件和一些unicode转义字符。我想把它转换成正确的chars显示。

E.g.:

Currently: \u0432\u0441\u0435 \u0433\u043e\u0442\u043e\u0432\u043e\u005c
Desired result: все готово

Notepad++ is already set to encode UTF8 without BOM. Opening the document and 'converting' (from the Encoding drop-down menu) doesn't do anything.

Notepad++已经被设置为没有BOM的UTF8编码。打开文档和“转换”(从编码下拉菜单)什么都不做。

How do I achieve this with notepad++?

如何用notepad++实现这个功能?

If not in Notepad++, is there any other way to do this for many files, perhaps by using some script?

如果不是在Notepad++中,是否还有其他方法可以对许多文件进行这样的操作,或者使用一些脚本?

2 个解决方案

#1


9  

You need a plugin named HTML Tag. Once plugin is installed, select your text and invoke command Plugins > HTML Tag > Decode JS (Ctrl+Shift+J).

你需要一个名为HTML标签的插件。一旦插件被安装,选择你的文本和调用命令插件> HTML标签>解码JS (Ctrl+Shift+J)。

#2


1  

I'm not aware of how you can do it natively in Notepad++ but as requested you can script it with Python:

我不知道如何在Notepad++中进行本机操作,但请您使用Python编写脚本:

import codecs

# opens a file and converts input to true Unicode
with codecs.open("escaped-unicode.txt", "rb", "unicode_escape") as my_input:
    contents = my_input.read()
    # type(contents) = unicode 

# opens a file with UTF-8 encoding
with codecs.open("utf8-out.txt", "wb", "utf8") as my_output:
    my_output.write(contents)

#1


9  

You need a plugin named HTML Tag. Once plugin is installed, select your text and invoke command Plugins > HTML Tag > Decode JS (Ctrl+Shift+J).

你需要一个名为HTML标签的插件。一旦插件被安装,选择你的文本和调用命令插件> HTML标签>解码JS (Ctrl+Shift+J)。

#2


1  

I'm not aware of how you can do it natively in Notepad++ but as requested you can script it with Python:

我不知道如何在Notepad++中进行本机操作,但请您使用Python编写脚本:

import codecs

# opens a file and converts input to true Unicode
with codecs.open("escaped-unicode.txt", "rb", "unicode_escape") as my_input:
    contents = my_input.read()
    # type(contents) = unicode 

# opens a file with UTF-8 encoding
with codecs.open("utf8-out.txt", "wb", "utf8") as my_output:
    my_output.write(contents)