用awk的printf到urlde code文本 [英] Using awk printf to urldecode text

查看:308
本文介绍了用awk的printf到urlde code文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用 AWK 来urlde code一些文​​本。

I'm using awk to urldecode some text.

如果我code中的字符串转换成像的printf 语句的printf%S,\\ X3D它正确输出 = 。如果我整个转义字符串作为一个变量一样。

If I code the string into the printf statement like printf "%s", "\x3D" it correctly outputs =. The same if I have the whole escaped string as a variable.

不过,如果我只有 3D ,我怎么能追加 \\ X 所以的printf 将打印 = ,而不是 \\ X3D

However, if I only have the 3D, how can I append the \x so printf will print the = and not \x3D?

我用 busybox的AWK 1.4.2 灰分外壳。

推荐答案

由于您使用的灰和Perl是不可用的,我假设你可能没有 GAWK

Since you're using ash and Perl isn't available, I'm assuming that you may not have gawk.

对于我来说,使用 GAWK busybox的AWK ,您的第二个例子中的工作方式相同第一个(我得到=从两个)除非我使用 - POSIX 选项(在这种情况下,我得到X3D为的两个的)

For me, using gawk or busybox awk, your second example works the same as the first (I get "=" from both) unless I use the --posix option (in which case I get "x3D" for both).

如果我用 - 非十进制数据 - 传统 GAWK 我得到=

code>,Busybox的 - 和版本号)

What version of AWK are you using (awk, nawk, gawk, busybox - and version number)?

编辑:

您可以通过添加零强制变量的字符串值成数字之一:

You can coerce the variable's string value into a numeric one by adding zero:

~/busybox/awk 'BEGIN { string="3D"; pre="0x"; hex=pre string; printf "%c", hex+0}'

这篇关于用awk的printf到urlde code文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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