请教下\x 开头的是啥编码? 站点日志好多这种, 也不像 url 和 utf8

2022-11-22 11:30:22 +08:00
 proxychains

@timestampNov 22, 2022 @ 09:15:39.105@version1agent.ephemeral_id6d0763e7-2caa-4560-945b-5fe36db0c7cdagent.id0905ccb1-6212-41de-b807-6b7c38583139agent.nameBKbQvh10443agent.typefilebeatagent.version8.4.0ecs.version8.0.0event.original71.1.1.1 - - [19/Jul/2022:15:03:12 +0800] "\x03\x00\x00/\xE0\x00\x00\x00\x00\x00Cookie: mstshash=Administr" 400 150 "-" "-"fields.tagnginx-tagloghost.nameBKbQvh10443input.typeloglog.file.path/var/wwwlogs/access.loglog.offset2,207message1.1.1.1 - - [19/Jul/2022:15:03:12 +0800] "\x03\x00\x00/\xE0\x00\x00\x00\x00\x00Cookie: mstshash=Administr" 400 150 "-" "-"tags[NGINX-ACCESS, beats_input_codec_plain_applied]_id23TmnIQBm8tgvL1Dd91O_indexaccess-logscore -

913 次点击
所在节点    问与答
5 条回复
nightwitch
2022-11-22 12:36:23 +08:00
纯字节表示,具体什么编码从一串字节里没法知道。 数了下有奇数个字节,大概率 utf-8
sinksmell
2022-11-22 12:43:01 +08:00
hello, 这个是 utf8 编码,将 \x 替换成 % 就得到了常见的 url encode / 百分号编码。

```shell
$ python3
Python 3.10.8 (main, Oct 13 2022, 09:48:40) [Clang 14.0.0 (clang-1400.0.29.102)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print ("\x03\x00\x00/\xE0\x00\x00\x00\x00\x00")

>>>

```

\x 后面跟的是 16 进制数字,可以还原成 []byte / []rune 从而得到原始字符串
proxychains
2022-11-22 13:07:10 +08:00
@nightwitch 感谢回复
proxychains
2022-11-22 13:07:17 +08:00
@sinksmell 感谢回复
2NUT
2022-11-22 13:31:38 +08:00
hex

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/897031

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX