如何在文本编辑器中找到特殊字符的字符代码? [英] How can I find the character code of a special character in my text editor?

查看:479
本文介绍了如何在文本编辑器中找到特殊字符的字符代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当将来自外部源的文本粘贴到纯文本编辑器(例如TextMate或Sublime Text 2)中时,一个常见的问题是通常还会粘贴特殊字符.这些字符中的一些可以很好地呈现,但是根据来源,某些字符可能无法正确显示(通常显示为带有问号的问号).

When pasting text from outside sources into a plain-text editor (e.g. TextMate or Sublime Text 2) a common problem is that special characters are often pasted in as well. Some of these characters render fine, but depending on the source, some might not display correctly (usually showing up as a question mark with a box around it).

这实际上是两个问题:

  1. 给出一个特殊字符(例如'或♥),我可以从文本编辑器中确定用于显示该字符的UTF-8字符代码,和/或将这些字符转换为它们的字符代码吗?

  1. Given a special character (e.g., ’ or ♥) can I determine the UTF-8 character code used to display that character from inside my text editor, and/or convert those characters to their character codes?

对于那些以垃圾形式出现的特殊"字符,有没有办法找出用来在源文本中显示该字符的编码,并且可以将这些字符以某种方式转换为UTF- 8?

For those "extra-special" characters that come in as garbage, is there any way to figure out what encoding was used to display that character in the source text, and can those characters somehow be converted to UTF-8?

推荐答案

我最喜欢的字符查找网站是 fileformat.info .他们具有出色的Unicode字符搜索功能,其中包含许多有关每个字符及其各种编码的有用信息.

My favorite site for looking up characters is fileformat.info. They have a great Unicode character search that includes a lot of useful information about each character and its various encodings.

如果看到带问号的问号,则表示您粘贴了无法解释的内容,通常是因为它不是合法的UTF-8(并非每个字节序列都是合法的UTF-8).一种可能是它的UTF-16具有您的编辑器所不期望的字节序模式.如果您可以将完整的原始源文件保存到文件中,则file命令通常是确定编码的最佳工具.

If you see the question mark with a box, that means you pasted something that can't be interpreted, often because it's not legal UTF-8 (not every byte sequence is legal UTF-8). One possibility is that it's UTF-16 with an endian mode that your editor isn't expecting. If you can get the full original source into a file, the file command is often the best tool for determining the encoding.

这篇关于如何在文本编辑器中找到特殊字符的字符代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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