Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Unicode again, in Win7 cmd

by hdb (Monsignor)
on Jun 07, 2013 at 11:25 UTC ( #1037655=perlquestion: print w/replies, xml ) Need Help??
hdb has asked for the wisdom of the Perl Monks concerning the following question:

I am not able to get unicode to work under Win7 command prompt. I am changing the code page to 65000 and want to print the diagonals from Re^2: Random maze generator. I cannot post all the permutations I have tried from the various Perl unicode tutorials and FAQs. So here is my skeleton code and I would like to know which combination of encode, decode, etc makes this work and what is not needed to do. Many thanks

use strict; use warnings; use Encode; use utf8; binmode STDOUT, ':encoding(UTF-8)'; my $enc = "utf-8"; system( "chcp 65000" ); # from node http://www.perlmonks.org/?node_id=843144 my $ne = "\xe2\x95\xb1"; my $nw = "\xe2\x95\xb2"; print $ne, $nw, "\n";

Replies are listed 'Best First'.
Re: Unicode again, in Win7 cmd
by choroba (Bishop) on Jun 07, 2013 at 11:27 UTC
    The characters are encoded in bytes. Therefore, the terminal should be set to utf-8, but the STDOUT should not. Remove the binmode. (You can safely remove use utf8 and use Encode, too. There is no unicode character in the code for the first one.)
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      Without binmode I get "••" instead of "╱╲".

      Sorry: was meant as reply to choroba.

        Nice. On my utf-8 terminal:
        echo ╱╲ | iconv -f utf8 -t cp1252
        ╱╲
        
        لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: Unicode again, in Win7 cmd (chcp 65001)
by Anonymous Monk on Jun 07, 2013 at 11:30 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1037655]
Front-paged by Corion
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2018-05-21 17:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?