Why does Perl lose foreign characters on Windows; can this be fixed (if so, how)?

Posted by Alex R on Stack Overflow See other posts from Stack Overflow or by Alex R
Published on 2010-12-24T16:01:46Z Indexed on 2010/12/24 22:54 UTC
Read the original article Hit count: 159

Filed under:
|
|

Note below how ã changes to a. NOTE2: Before you blame this on CMD.EXE and Windows pipe weirdness, see Experiment 2 below which gets a similar problem using File::Find.

The particular problem I'm trying to fix involves working with image files stored on a local drive, and manipulating the file names which may contain foreign characters. The two experiments shown below are intermediate debugging steps.

The ã character is common in latin languages. e.g. http://pt.wikipedia.org/wiki/Cão

Experiment 1

alt text

Experiment 2

To get around my particular problem, I tried using File::Find instead of piped input. The issue actually gets worse: alt text


Debugging update:

I tried some of the tricks listed at http://perldoc.perl.org/perlunicode.html, e.g. use utf8, use feature 'unicode_strings', etc, to no avail.


Environment and Version Info

The OS is Windows 7, 64-bit.

The Perl is:

This is perl 5, version 12, subversion 2 (v5.12.2) built for MSWin32-x64-multi-thread
(with 8 registered patches, see perl -V for more detail)

Copyright 1987-2010, Larry Wall

Binary build 1202 [293621] provided by ActiveState http://www.ActiveState.com
Built Sep  6 2010 22:53:42

© Stack Overflow or respective owner

Related posts about perl

Related posts about unicode