小编Dav*_*eks的帖子

如何在 perl v5.24 中获取 unicode 代码点?

我想记录作为参数剪切并粘贴到 bash 中的字符串的十六进制 unicode 代码点。ord 不这样做;ord 似乎只在 ascii 范围内工作。

\n\n

我发现的关于 ord 的大部分内容至少已有六年或更久了,并且不再相关,因为我使用的是 v5.24,我读过的 v5.24 内置了 unicode 支持。\n在 python 中,它是琐碎的:

\n\n
\nfor i in unicode(sys.argv[1], \'utf-8\'):\n    print i.encode("utf_16_be").encode("hex")\n
Run Code Online (Sandbox Code Playgroud)\n\n

它在 bash 中工作。\n我认为问题在于 ord 函数本身,它似乎没有针对 unicode 进行更新。

\n\n
\n# ord.pl does not provide the unicode code point for a pasted variable.\nuse strict;\nuse warnings;\n#use charnames (); #nope.\n#use feature \'unicode_strings\'; #nope.  Already automatically using as of v5.12.\n#use utf8; #nope.\n#binmode(STDOUT, ":encoding(UTF-8)"); #nope.\n\nmy $arg = "";\n\nforeach $arg  (@ARGV) {\n  print $arg . " is " …
Run Code Online (Sandbox Code Playgroud)

unicode perl ord

5
推荐指数
1
解决办法
1237
查看次数

标签 统计

ord ×1

perl ×1

unicode ×1