File tree 2 files changed +16
-8
lines changed
2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -216,17 +216,12 @@ sub prompt ($;$) { ## no critic
216
216
print " $def \n " ;
217
217
}
218
218
else {
219
- my $codepage ;
220
- if ($Is_Win32 ) {
221
- require Win32::Console;
222
- require Encode;
223
- $codepage = Win32::GetConsoleCP(); # get the input code page
224
- }
225
219
$ans = <STDIN >;
226
220
if ( defined $ans ) {
227
221
$ans =~ s {\015 ?\012 $} {} ;
228
- if ($Is_Win32 and defined $codepage and length $codepage ) {
229
- $ans = Encode::decode(" cp" . $codepage , $ans );
222
+ if ($Is_Win32 and $CAN_DECODE ) {
223
+ my $codepage = $ExtUtils::MakeMaker::Locale::ENCODING_CONSOLE_IN ;
224
+ $ans = Encode::decode($codepage , $ans );
230
225
}
231
226
}
232
227
else { # user hit ctrl-D
Original file line number Diff line number Diff line change @@ -44,3 +44,16 @@ ok( !-t STDIN, 'STDIN not a tty' );
44
44
45
45
is( prompt(" Foo?" , ' Bar!' ), ' From STDIN' , ' from STDIN' );
46
46
like( $stdout -> read , qr / ^Foo\? \[ Bar!\]\s *$ / , ' question' );
47
+
48
+ {
49
+ my $CAN_DECODE = eval { require ExtUtils::MakeMaker::Locale; };
50
+ SKIP: {
51
+ skip ' Encode not available' , 1 unless $CAN_DECODE ;
52
+ skip ' Not MSWin32' , 1 unless $^O eq ' MSWin32' ;
53
+ local $ExtUtils::MakeMaker::Locale::ENCODING_CONSOLE_IN = " cp850" ;
54
+ $ENV {PERL_MM_USE_DEFAULT } = 0;
55
+ $stdin -> write (" \x{86}\x{91} " ); # åæ in cp850
56
+ is( prompt(" Foo?" , ' Bar!' ), " \x{e5}\x{e6} " ,
57
+ ' read cp850 encoded letters from STDIN' );
58
+ }
59
+ }
You can’t perform that action at this time.
0 commit comments