List Info

Thread: Re: cmd /u




Re: cmd /u
country flaguser name
United States
2007-04-10 21:57:16
On approximately 4/10/2007 10:18 AM, came the following
characters from 
the keyboard of Glenn Linderman:
> On approximately 4/10/2007 9:47 AM, came the following
characters from 
> the keyboard of Jan Dubois:
>   
>> On Tue, 10 Apr 2007, Glenn Linderman wrote:
>>     
>>> Thanks for the response. But cp850 and cp1252
are not Unicode, but
>>> byte-size subset. That allows translation of
codes common to both
>>> subsets to be displayed properly on the default
console (which uses
>>> code page 850) in spite of cp1252 being the
default code page for
>>> windows programs.
>>>       
>> I think `cmd /u` only switches the output of
cmd.exe *internal*
>> commands to Unicode *if* you are redirecting the
output and not
>> displaying it on the console.  E.g.
>>
>>     cmd /u /c dir > dir.lst
>>
>> will write dir.lst in UCS2.
>>
>> To display Unicode characters in the console
window, you must use
>> a TTF font like "Lucida Console" because
the raster fonts don't
>> contain all the codepoints.  Then you can switch
the codepage to
>> UTF8:
>>
>>     chcp 65001
>>
>> I think there is a problem with running batch files
if you switch
>> to the UTF8 codepage (which isn't really documented
to work).
>>
>> Here is a list of requirements that must be met for
a font to
>> be used with cmd.exe:
>>
>>     http://support.microsoft.com/default.aspx?scid=kb
;EN-US;Q247815
>>
>> Cheers,
>> -Jan
>>     
>
> Hi Jan,
>
> Thanks for the response.
>
> I've been using Lucida Console for my CMD Prompt window
for a long time, 
> so that is not a problem 
>
> Last time I looked into code page 65001 it seemed that
it certainly 
> wasn't generally functional... but mostly only usable
with the character 
> conversion APIs.  On the other hand, as you suggest,
using chcp 65001 in 
> the CMD prompt window, together with
>
> binmode(STDOUT,':encoding(UTF-8)');
> print "x";
>
> seems to work to produce output of Unicode characters
on the console. 
> And, also as you mentioned, batch files don't seem to
quite run right...
>
> And I can't successfully paste the Unicode codepoint
U+0163 into the 
> perl interactive input stream from the character map,
whether I
>
> use utf8;
>
> or not.  It seems to terminate the Perl instance :(
>   

Just for the record, since the cmd /u parameter is not a
necessary part 
of this solution, a complete solution for displaying Unicode
on console 
windows seems to be:

1) Choose Lucida Console as the default font for CMD Prompt
windows, in 
the properties of the CMD Prompt window, started in any of
the ways in 
which you start them.

2) Use the following sample Perl code, or adjust
appropriately for your 
specifics. One could even go as far as parsing the output of
a 
parameterless chcp to obtain the active code page prior to
changing it 
the first time, and changing it back to that....

system('chcp 65001 >nul:');
binmode(STDOUT,':encoding(UTF-8)');
print "x";
system('chcp 1252 >nul:');

-- 
Glenn -- http://nevcal.com/
===========================
A protocol is complete when there is nothing left to
remove.
-- Stuart Cheshire, Apple Computer, regarding Zero
Configuration Networking

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Userslistserv.ActiveState.com
To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )