when the Cyrillic encoding is used - it's there (the readable text). what I want is to open this .txt file with notepad and to have that readable text.

It sounds like the real question is: "How do I get Notepad to treat and display a plain text file using my Cyrillic encoding?" If there were such a thing as "notepadmonks.org", this question would be for them, not for us.

Based on what you have said, MS-Word lets you specify what character encoding to use when opening/displaying the file, and when you do this, it actually shows the text the way you want/expect. If notepad can't do this, then it's a problem with notepad, not a problem with how perl is creating the text file.

If you are able to view/edit Cyrillic text data in notepad with other text files, then the problem is simply that notepad is using one specific character encoding for Cyrillic, and this encoding is different from the one that perl is writing when it outputs the plain text file, and different from the encoding that you specify when you load the plain text into MS-Word.

In that case, figure out which encoding notepad uses for Cyrillic, and change the perl script to output the text file in that particular character set.

Try this: create a simple Cyrillic plain-text file using notepad and your keyboard, then use MS-Word to open that file. What character-encoding do you need to select in MS-Word in order to display this test file correctly? And when you opened your perl script's output in MS-Word, which encoding did you choose that time?

If your notepad output file and your perl output file are using two different encodings, change your perl script so that it will output the file using the encoding that notepad uses. It should be a simple matter of changing the "open" statement that you use in perl for the output file:

my $filename = 'some_filename.txt' my $output_encoding = 'whatever_it_is_that_notepad_wants'; open( OUT, ">:encoding($output_encoding)", $filename ) or die "$filena +me: $!"; # or, if you are just printing to STDOUT: binmode( STDOUT, ":encoding($output_encoding)" );
(In case it helps, perl uses names like "koi8-r", and "cp1251", among others, for non-unicode Cyrillic character encodings. Refer to Encode to see how to list all available character sets.)

(updated code snippet to use a single variable name consistently for "filename")


In reply to Re^3: Cyrillic to plain text by graff
in thread Cyrillic to plain text by Arba

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.