Re: Converting codepages to UTF8



P wrote:

Hello,

Is there a Perl module which implements converting of codepages
(such as you get when running "chcp" in a command prompt) to UTF8?
Something that allows me to specify, for example, codepage 437 and
then converting it to UTF8. I've looked through the documentation for
the module Encode, but it doesn't seem to deal with codepages at all.

Thank you for any information you can provide that will nudge me in
the
right direction.


Best regards,
Angela Druss


The Encode module should do what you want. As far as I know, Encode supports all the codepages out there. Assuming that $filename has raw octets in the native codepage, something like:

$unicodefn = decode("cp437", $filename);

.... should do the trick. The resulting string will be in Perl's Unicode format -- keep in mind that while Perl uses UTF-8 internally, Perl treats Unicode strings differently from strings of raw UTF-8 octets.

--
Donald King, a.k.a. Chronos Tachyon
http://chronos-tachyon.net/
.



Relevant Pages

  • Converting codepages to UTF8
    ... Is there a Perl module which implements converting of codepages ... then converting it to UTF8. ... but it doesn't seem to deal with codepages at all. ...
    (comp.lang.perl.misc)
  • Re: Can I upload Perl program in unicode?
    ... the upload. ... not Perl itself. ... And I'm sure there are other tools for converting as well. ... I had some problems with DBI and MySQL with Perl and UTF8 but I managed to get that to work too. ...
    (comp.lang.perl.misc)
  • Re: Can I upload Perl program in unicode?
    ... the upload. ... not Perl itself. ... I am not sure who it handles UTF8, ... sure there are other tools for converting as well. ...
    (comp.lang.perl.misc)
  • Re: Converting codepages to UTF8
    ... command prompt) to UTF8? ... specify, for example, codepage 437 and then converting ... codepages at all. ... chcp is a command to change the parameters of the display. ...
    (comp.lang.perl.misc)