如何摆脱这个unicode字符? [英] How do I get rid of this unicode character?

查看:188
本文介绍了如何摆脱这个unicode字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么主意如何从一堆文本文件中消除这个令人讨厌的字符U + 0092?我已经尝试了以下所有方法,但是没有用.从字符映射中被称为 U + 0092 + control

Any idea how to get rid of this irritating character U+0092 from a bunch of text files? I've tried all the below but it doesn't work. It's called U+0092+control from the character map

sed -i 's/\xc2\x92//' *
sed -i 's/\u0092//' *
sed -i 's///' *

啊,我找到了一种方法:

Ah, I've found a way:

CHARS=$(python2 -c 'print u"\u0092".encode("utf8")')
sed 's/['"$CHARS"']//g'

但是有直接的sed方法吗?

But is there a direct sed method for this?

推荐答案

尝试sed "s/\`//g" *. (我添加了g,因此它将删除找到的所有反引号).

Try sed "s/\`//g" *. (I added the g so it will remove all the backticks it finds).

编辑:这不是OP想要删除的背景.

EDIT: It's not a backtick that OP wants to remove.

按照中的解决方案进行操作问题,它应该可以工作:

Following the solution in this question, this ought to work:

sed 's/\xc2\x92//g'

要演示它的作用,

$ CHARS=$(python -c 'print u"asdf\u0092asdf".encode("utf8")')

$ echo $CHARS
asdf<funny glyph symbol>asdf

$ echo $CHARS | sed 's/\xc2\x92//g'
asdfasdf

看到这是您已经尝试过的东西,也许您的文本文件中不是U + 0092吗?

Seeing as it's something you tried already, perhaps what is in your text file is not U+0092?

这篇关于如何摆脱这个unicode字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆