隐形角色抬头? (PHP)

发布于 2024-11-05 07:26:09 字数 390 浏览 4 评论 0原文

我正在解析一些包含不可见字符的文件。这些文件的结构很奇怪,因此有时我必须在 9 或 10 个不可见字符之后才能找到真正的信息。是的...

无论如何,我有一些文件似乎包含我的正则表达式还不知道的不可见字符。有没有某种方法可以通过函数传递字符来查找其字符代码?因为它是看不见的,所以我真的没有什么可继续的,哈哈。

目前我正在使用以下正则表达式来查找不可见字符。 (从这个问题找到)

public $invisibles='\x00-\x09\x0B\x0C\x0E-\x1F\x7F';

I'm parsing some files that contain invisible characters. The files are structured strangely so that I sometimes have to find real information after 9 or 10 invisible characters. Yeah...

Anyway, I have some files that seem to have invisible characters that my regex doesn't yet know about. Is there some way to pass a character through a function to look up it's character code? Since it's invisible, I don't really have much else to go on, ha.

Currently I'm using the following regular expression to find invisible characters. (found from this question)

public $invisibles='\x00-\x09\x0B\x0C\x0E-\x1F\x7F';

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

趁微风不噪 2024-11-12 07:26:10

你的是控制角色。但另一个真正的不可见字符是 \xA0 不间断空格。

无论如何,要找出困扰您的问题,请首先将其隔离(substr 如果可以的话) ,然后通过 ord() 来获取 ASCII 数字:

preg_match('/\W/', $str, $match);   // find first non-letter
print dechex(ord($match[0]));

(dechex 是将其打印为十六进制)

不过实际上,您应该下载一个用于此类目的的十六进制编辑器。

Yours are control characters. But another real invisible character is \xA0 the non-breaking space.

Anyway to find out which is bugging you, first isolate it (substr if you can), and then pass it through ord() to get the ASCII number:

preg_match('/\W/', $str, $match);   // find first non-letter
print dechex(ord($match[0]));

(dechex is for printing it out as hex)

Though really, you should just download a hexeditor for such purposes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文