0

Here is the code where I get the error:

  while (defined(my $i = <READ>))
  {
    my $text_str = decode('utf-8', $i);
    $text_str =~ s/\xA7/ยง/g;
    $text_str =~ s/\t/\n/g;
    print WRITE $text_str;
  }

The error is:

Wide character in print at script/conv_charset.pl line 34,

How can I fix this? I want to get rid of this error.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • 1
    You decoded your inputs, but you didn't encode your outputs. Add `use open ':std', ':encoding(UTF-8)';` (which will probably handle the decoding too). โ€“ ikegami Nov 08 '22 at 13:42
  • 1
    Or use `binmode STDOUT, ':utf8';` as one of first instructions in your code. Or open your file for output with `open my $fh, '>:encoding(utf8)', $fname`. Documentation [binmode](https://perldoc.perl.org/functions/binmode) โ€“ Polar Bear Nov 09 '22 at 01:45
  • I have alrady used "use Encode qw(encode decode);" this command at the begining of the code. So this also did not solved the issue. โ€“ Sai Pradyumna Tumma Nov 15 '22 at 12:38

0 Answers0