in reply to Re: UTF-8 issues with Perl in general and with Spreadsheet::WriteExcel
in thread UTF-8 issues with Perl in general and with Spreadsheet::WriteExcel

The Spreadsheet::WriteExcel issue got cleared up after the first answer, everything is fine with that. Thanks for the link, though, John, it proved to be pretty handy.

I made a couple of meek attempts at finding out what is wrong with input from console, without success. I take input from the keyboard with <STDIN>, save it in a scalar variable and write it to a utf-8 txt file, the characters get corrupted. If I binmode STDIN beforehand, I get an error message about characters not mapping to Unicode and get character codes like \x{38232E2}\x81\xA1 in the output txt. Fixing this on my own system is not the goal; this is for a script I'm distributing quite widely so it should work on any random computer (with Windows, Mac OS or Linux...)

As it stands, I think I'll just tell the users to stick to ASCII or they may get corrupted characters. No drama, but it's a bit annoying to have to do that.

Here's the code in case somebody wants to poke it or has an idea:
binmode STDIN, ':encoding(utf8)'; print "\nEnter text: "; chomp ($text = <STDIN>); open (TEST, ">:encoding(UTF-8)", "test.txt") or die "Can't open file: +$!"; print TEST $text;
  • Comment on Re^2: UTF-8 issues with Perl in general and with Spreadsheet::WriteExcel
  • Download Code