如何在 Notepad++ 中替换 Unicode 字符

如何在 Notepad++ 中替换 Unicode 字符

我有一个 .xlf 文件,如下图所示:

在此处输入图片描述

我想知道如何搜索和替换 unicode 字符“xE5”“æ” 我以为我可以搜索:^0145 =xE5并替换“æ”,但没有效果。

如果这不可能,我可以使用另一个文本编辑器(例如 ultraedit)。

以下是从文件中粘贴的文本:

<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-strict.xsd">
  <file xmlns:bind="http://bind.sorona.se" original="CTO12623_1_en-GB-da.xml" source-language="en" datatype="xml" date="2015-11-11T15:35:51Z" target-language="da" product-name="Anders_LP8504_151111" bind:file-id="78452" bind:file-hash="85075c54359fa47b087d6c67ec967f43">
    <header>
      <tool tool-name="Sorona TMS" tool-id="bind" tool-version="3.1.5" tool-company="Sorona Innovation" />
      <count-group name="word-count">
        <count count-type="total" unit="word">2743</count>
      </count-group>
    </header>
    <body>
      <trans-unit id="e1ca41ef868a74944745b8cd1dfa59e7" translate="yes" approved="no" restype="string" resname="p">
        <source>The trench compactor LP 8504 is a radio controlled trench compactor. It has a robust design and is suitable for compaction of medium to deep layers of cohesive and granular soils on limited areas such as trenches, construction back-fills and on roads. No other use is permitted.</source><seg-source><mrk mtype="seg" mid="1">The trench compactor LP 8504 is a radio controlled trench compactor. It has a robust design and is suitable for compaction of medium to deep layers of cohesive and granular soils on limited areas such as trenches, construction back-fills and on roads. No other use is permitted.</mrk></seg-source>
        <target state="translated"><mrk mtype="seg" mid="1">Vibrationstromlen LP 8504 er radiostyret. Den har et robust design og er beregnet til komprimering af middel til dybe lag af sammenh篧ende og granuleret jord p塢egr篳ede omr楥r s塳om gr

答案1

我想知道如何搜索和替换 unicode 字符xE5"æ

请注意,æ实际上是 Unicode ,00E6而不是00E5

搜索和替换并不是显示正确字符的正确方法。

<?xml version="1.0" encoding="utf-8"?>

上面指出了编码是,utf-8但是文件实际上被编码为ANSI

您需要将文件正确转换为UTF-8,如下所示:

  1. 打开测试文件.xlf

  2. 文件看起来像:

    在此处输入图片描述

    Unicode 显示不正确。

  3. 菜单 >编码> 选择以 ANSI 编码

    在此处输入图片描述

  4. 文件看起来像:

    在此处输入图片描述

    Unicode 正确显示。

  5. 选择所有文件内容 ( ctrl+ a)

  6. 菜单 >编码> 选择转换为 UTF-8

    在此处输入图片描述

  7. 保存文件 ( ctrl+ s)

  8. 关闭并重新打开。

  9. 文件现在正确编码为 UTF-8,并且 Unicode 字符可以正确显示。


您怎么知道该文件实际上是 ANSI 的?

cygwinfile实用程序显示此内容(转换前后):

DavidPostill@Hal /f/test
$ file -i Testfile*.xlf
Testfile.xlf:          application/xml; charset=iso-8859-1
TestfileConverted.xlf: application/xml; charset=utf-8

答案2

如果您想完全删除 UTF-8/unicode 字符,请单击EncodingNPP 并按顺序执行以下步骤:

  1. 选择使用 UTF-8 编码(如果它目前是 ANSI)
  2. 选择转换为 ANSI(也处于编码下)
  3. 保存存档

当我这样做时,所有的 UTF-8/unicode 字符都会消失。

相关内容