in reply to Re^2: Encoding problem with function in C library
in thread Encoding problem with function in C library
Win32::Console gives you the interface to ->OutputCP:
#!perl use strict; use warnings; use charnames ':full'; use Win32::Console; my $c = Win32::Console->new(STD_OUTPUT_HANDLE); $c->OutputCP(65001); # we write UTF-8 binmode STDOUT, ':encoding(UTF-8)'; print "\N{INFINITY}\n";
In my tests, the output code page persisted after the program run, so you might (or might not) want to save/restore the codepage:
my $oldCP = $c->OutputCP(); $c->OutputCP(65001); # we write UTF-8 END{ if( $c ) { $c->OutputCP($oldCP); # we write UTF-8 } } ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Encoding problem with function in C library (updated)
by haukex (Archbishop) on Dec 22, 2022 at 13:35 UTC | |
by Corion (Patriarch) on Dec 22, 2022 at 13:43 UTC | |
by haukex (Archbishop) on Dec 22, 2022 at 13:54 UTC |