Javascript decodedURI未在HTML中正确显示

Javascript decodedURI未在HTML中正确显示,javascript,html,perl,Javascript,Html,Perl,我有一个用perl编码的字符串,使用 uri_escape ($string); 然后我将其传递给Javascript,并通过 fileName = decodeURIComponent ($somevariable); 然后我对变量发出警报,字符串正确显示(在本例中) 但是,在HTML中,它显示为 his33a%3BCell-Line_Fly-biotin-tagged-H33%3BTissue_embryo-derived-cell-line%3BDevelopmental-Stage_

我有一个用perl编码的字符串,使用

uri_escape ($string);
然后我将其传递给Javascript,并通过

fileName = decodeURIComponent ($somevariable);
然后我对变量发出警报,字符串正确显示(在本例中)

但是,在HTML中,它显示为

his33a%3BCell-Line_Fly-biotin-tagged-H33%3BTissue_embryo-derived-cell-line%3BDevelopmental-Stage_late-embryonic-stage%3BCompound_80-600-mM%3Bextract_soluble-fraction%3Bsampling_time_point_1-%E2%80%93-2-hours%3BDNA-tiling-array%3BRep-2%3BDmel_r54%3BmodENCODE_2523%3BGSM333854.wiggle

Perl/
URI::Escape
URI\u Escape
和JavasScript的
encodeURIComponent
做的事情不一样。为了保证兼容性,请使用CPAN中的
JavaScript
模块:

use 5.014;
use warnings;
use JavaScript;
use URI::Escape;

my $rt = JavaScript->create_runtime();
my $cx = $rt->create_context();
my $string = 'his33a;Cell-Line_Fly-biotin-tagged-H33;Tissue_embryo-derived-cell-line;Developmental-Stage_late-embryonic-stage;Compound_80-600-mM;extract_soluble-fraction;sampling_time_point_1-–-2-hours;DNA-tiling-array;Rep-2;Dmel_r54;modENCODE_2523;GSM333854.wiggle';

# Perl:
say uri_escape($string);
# his33a%3BCell-Line_Fly-biotin-tagged-H33%3BTissue_embryo-derived-cell-line%3BDevelopmental-Stage_late-embryonic-stage%3BCompound_80-600-mM%3Bextract_soluble-fraction%3Bsampling_time_point_1-%E2%80%93-2-hours%3BDNA-tiling-array%3BRep-2%3BDmel_r54%3BmodENCODE_2523%3BGSM333854.wiggle

# JavaScript:
$cx->eval(qq|
function escape_uri(string) { return encodeURIComponent(string) }
|);
say $cx->call('escape_uri', $string);
# his33a%3BCell-Line_Fly-biotin-tagged-H33%3BTissue_embryo-derived-cell-line%3BDevelopmental-Stage_late-embryonic-stage%3BCompound_80-600-mM%3Bextract_soluble-fraction%3Bsampling_time_point_1-%C3%A2%C2%80%C2%93-2-hours%3BDNA-tiling-array%3BRep-2%3BDmel_r54%3BmodENCODE_2523%3BGSM333854.wiggle

我想你想要
解码URI
,非
decodeURIComponent
.decodeURI显示his33a%3BCell-Line\u Fly-biotin-taged-H33%3BIssue\u胚胎衍生细胞系%3B发育期\u晚期胚胎期%3BCompound\u 80-600-mM%3BE提取可溶性分数%3B采样时间点\u 1-%E2%80%93-2小时%3BDNA拼接阵列%3BRep-2%3BDmel\u r54%3BmodENCODE\u 2523%3BG854decodeURI它也不能正确地显示在警报中。
use 5.014;
use warnings;
use JavaScript;
use URI::Escape;

my $rt = JavaScript->create_runtime();
my $cx = $rt->create_context();
my $string = 'his33a;Cell-Line_Fly-biotin-tagged-H33;Tissue_embryo-derived-cell-line;Developmental-Stage_late-embryonic-stage;Compound_80-600-mM;extract_soluble-fraction;sampling_time_point_1-–-2-hours;DNA-tiling-array;Rep-2;Dmel_r54;modENCODE_2523;GSM333854.wiggle';

# Perl:
say uri_escape($string);
# his33a%3BCell-Line_Fly-biotin-tagged-H33%3BTissue_embryo-derived-cell-line%3BDevelopmental-Stage_late-embryonic-stage%3BCompound_80-600-mM%3Bextract_soluble-fraction%3Bsampling_time_point_1-%E2%80%93-2-hours%3BDNA-tiling-array%3BRep-2%3BDmel_r54%3BmodENCODE_2523%3BGSM333854.wiggle

# JavaScript:
$cx->eval(qq|
function escape_uri(string) { return encodeURIComponent(string) }
|);
say $cx->call('escape_uri', $string);
# his33a%3BCell-Line_Fly-biotin-tagged-H33%3BTissue_embryo-derived-cell-line%3BDevelopmental-Stage_late-embryonic-stage%3BCompound_80-600-mM%3Bextract_soluble-fraction%3Bsampling_time_point_1-%C3%A2%C2%80%C2%93-2-hours%3BDNA-tiling-array%3BRep-2%3BDmel_r54%3BmodENCODE_2523%3BGSM333854.wiggle