Portál AbcLinuxu, 18. prosince 2025 07:03
Use of uninitialized value $x in scalar assignment at PERL2EXE_STORAGE/utf8_heavy.pl line 242.
Use of uninitialized value $x in pattern match (m//) at PERL2EXE_STORAGE/utf8_heavy.pl line 243.
Unknown encoding 'CP852' at c:\Robotek\plbot2.4/nastaveni.pl line 88
Onen problemovy kod je
use Encode;
sub vypis {
my $testext = shift;
$testext = decode("UTF8",$testext);
$testext = encode("CP852",$testext);
print $testext;
}
&vypis("Něco s háčkama");
V podstatě jde mi o to aby program v perlu dokázal vypisovat korektne hačky/čárky do konzole.
Kompilator Perl2Exe V9.110 registrovany. Perl 5.10.1 a je to kompilovano na W7.
Řešení dotazu:
use strict;
use warnings;
use utf8;
use Encode;
sub vypis {
my $testext = decode_utf8(shift);
return encode("CP852",$testext);
}
print vypis("Něco s háčkama");
Soubor musi samozrejme byt v utf8 encoding.
`recode UTF-8..CP1250 $file`;
# recode --help Free `recode' converts files between various character sets and surfaces. ...
use encoding "utf8", STDOUT => "cp852";
sub vypis {
my $testext = shift;
print $testext;
}
&vypis("Něco s háčkama");
nestačí něco takového?
require 'unicore/lib/gc_sc/Digit.pl'; # odstrani error s utf8_heavy # to ostatni require 'Encode.pm'; require 'Encode/Alias.pm'; require 'Encode/Byte.pm'; require 'Encode/Config.pm'; require 'Encode/Encoding.pm';
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.