CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Command Line Encoding Setting

 



degoor
New User

Dec 8, 2012, 11:58 PM

Post #1 of 2 (932 views)
Command Line Encoding Setting Can't Post

Hello!

I have just started to learn Perl and I have an issue with the encoding of the command prompt.

My system: Windows XP Professional SP3,
Perl version: Strawberry Perl v5.14.2 built for MSWin32-x86-multi-thread

I need to print in the command prompt some Cyrillic messages using print .

For example


Code
#!/perl 
print "Аз съм българин.\n";


If I save that as bg.pl and write in the command prompt


Code
perl bg.pl


I get some ugly characters.

When I write in the console


Code
chcp


I get


Code
Active code page: 866


I use EditPlus editor that can save text files as ANSI, Unicode, Unicode big endian, UTF-8, UTF-8+BOM files.


Could you kindly help me on the matter?


degoor
New User

Dec 9, 2012, 10:50 AM

Post #2 of 2 (916 views)
Re: [degoor] Command Line Encoding Setting [In reply to] Can't Post

OK, here is how I solved the matter:

I saved bg.pl in all possible formats in the text editor: ANSI, Unicode, Unicode big endian, UTF-8, UTF-8+BOM.

When I saved the file as 'Unicode' and I tried


Code
type bg.pl


the Cyrillic letters appeared correctly.

Since chcp command showed that the code page used by the DOS prompt is 'cp866', I added after #!/perl line the following:


Code
use encoding 'cp866';


That solved the problem.

Thanks for your reading!

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives