Sac*_*rni 0 perl html-entities
我有一个测试字符串,如:
my $input = "testing &test ₨";
my $output = HTML::Entities::encode_entities($str,"<>&\"'");
Run Code Online (Sandbox Code Playgroud)
期望的输出是
testing &test ₨
Run Code Online (Sandbox Code Playgroud)
但HTML :: Entities :: encode_entities正在对此进行编码
testing &test &#8360;
Run Code Online (Sandbox Code Playgroud)
总而言之,我希望HTML :: Entities仅在不表示HTML实体编号的情况下对"&"字符进行编码.
您需要先解码字符串,然后对其进行编码:
#!/usr/bin/env perl
use strict; use warnings; use v5.10;
use HTML::Entities ();
my $input = "testing &test ₨";
$input = HTML::Entities::encode( HTML::Entities::decode( $input ) );
say $input;
Run Code Online (Sandbox Code Playgroud)
结果是
testing &test ₨
Run Code Online (Sandbox Code Playgroud)
20A8是十六进制版本8360.
| 归档时间: |
|
| 查看次数: |
448 次 |
| 最近记录: |