如何从 .txt 文件中删除 <96>
How to remove <96> from a .txt file
我收到一个 .txt
文件,里面有很多 <96>
应该是 space。
在 vi 中,我做了:
:%s/<96>//g
或
:%s/\<96>\//g
但它仍然存在。我做了 dos2unix,但它仍然没有删除它。是统一码吗?如果是,我该如何删除它?谢谢!
很有可能这不是四个 文字 字符 <
、9
、6
和 >
.相反,它们可能是由字节 0x96
形成的 单个 字符,Vim 呈现为 <96>
.
你可以通过执行(从bash
)看到:
printf '123\x96abc\x96def' > file.txt ; vi file.txt
你应该看到:
123<96>abc<96>def
要摆脱它们,您可以将 sed
与类似的东西一起使用(假设您的 sed
有就地替换):
sed -i.save 's/\x96//g' file.txt
你 可以 也可以在 vim
本身中执行此操作,你只需要意识到你可以使用 CTRL-V[= 输入任意字符64=](或 CTRL-Q 如果 CTRL-V 设置为粘贴)。有关详细信息,请参阅 here,在此处进行解释和缩短以确保答案是独立的:
It is possible to enter any character which can be displayed in your current encoding, if you know the character value, as follows (^V
means CTRL-V
, or CTRL-Q
if you use CTRL-V
to paste):
- Decimal:
^Vnnn
, 000..255
.
- Octal:
^Vonnn
, 000..377
.
- Hex:
^Vxnn
, 00..ff
.
- Hex, BMP Unicode:
^Vunnnn
, 0000..FFFF
.
- Hex, any Unicode:
^VUnnnnnnnn
, 00000000..7FFFFFFF
.
In all cases, initial zeros may be omitted if the next character typed is not a digit in the given base (except, of course, that the value zero must be entered as at least one zero).
Hex digits A-F, when used, can be typed in upper or lower case, or even in any mixture of them.
因此您想要的键序列(假设您希望将它们替换为空格)是:
:%s/<CTRL-V>x96/ /g
我收到一个 .txt
文件,里面有很多 <96>
应该是 space。
在 vi 中,我做了:
:%s/<96>//g
或
:%s/\<96>\//g
但它仍然存在。我做了 dos2unix,但它仍然没有删除它。是统一码吗?如果是,我该如何删除它?谢谢!
很有可能这不是四个 文字 字符 <
、9
、6
和 >
.相反,它们可能是由字节 0x96
形成的 单个 字符,Vim 呈现为 <96>
.
你可以通过执行(从bash
)看到:
printf '123\x96abc\x96def' > file.txt ; vi file.txt
你应该看到:
123<96>abc<96>def
要摆脱它们,您可以将 sed
与类似的东西一起使用(假设您的 sed
有就地替换):
sed -i.save 's/\x96//g' file.txt
你 可以 也可以在 vim
本身中执行此操作,你只需要意识到你可以使用 CTRL-V[= 输入任意字符64=](或 CTRL-Q 如果 CTRL-V 设置为粘贴)。有关详细信息,请参阅 here,在此处进行解释和缩短以确保答案是独立的:
It is possible to enter any character which can be displayed in your current encoding, if you know the character value, as follows (
^V
meansCTRL-V
, orCTRL-Q
if you useCTRL-V
to paste):
- Decimal:
^Vnnn
,000..255
.- Octal:
^Vonnn
,000..377
.- Hex:
^Vxnn
,00..ff
.- Hex, BMP Unicode:
^Vunnnn
,0000..FFFF
.- Hex, any Unicode:
^VUnnnnnnnn
,00000000..7FFFFFFF
.In all cases, initial zeros may be omitted if the next character typed is not a digit in the given base (except, of course, that the value zero must be entered as at least one zero).
Hex digits A-F, when used, can be typed in upper or lower case, or even in any mixture of them.
因此您想要的键序列(假设您希望将它们替换为空格)是:
:%s/<CTRL-V>x96/ /g