0

I have a text file encoded in Windows-1250. I'm using Windows 7 EN.

I would like to iterate through this file line by line in Perl code with print. In console I cannot see the diacritic signs.

Could you give me any solution?

Alois Mahdal
  • 10,763
  • 7
  • 51
  • 69
ruhungry
  • 4,506
  • 20
  • 54
  • 98
  • 2
    Please post your code so far. What do you see instead of the expected characters? Don't forget your terminal (or Windows' `cmd.exe`) will make an interpretation of the encoding too - it is possible to have everything correct in code but still not see what you want! – Neil Slater Mar 31 '13 at 18:46

1 Answers1

2

It depends on what you are going to do with the text, but for many cases it's possible to code independently on encoding. Anyway, if you redirect output to a file and the result is OK (read: can be displayed opened by text editor in Windows 1250 mode using proper font), your code is not the problem.

The other thing is that you want to see CE characters in your console. For that to work you need to do:

  • set your console window to use font capable of displaying them (you may need to install such font, I don't remember The Right Way in Win 7)

  • set your console to Windows-1250 mode using command chcp 1250

Note that this is basically the same you would need to do with your viewer or editor to see the characters. Except that while many editors are able to detect encoding themselves (sometimes even correctly) and pick the right font, consoles typically need help from you.

Your problem might be similar to what has been solved here. I also recommend reading the other post I'm referencing there.

Community
  • 1
  • 1
Alois Mahdal
  • 10,763
  • 7
  • 51
  • 69