| Store | Cart
Lists » pdk

weird string literal encoding

From: Yu-ji Hosokawa <yu-...@hoso.net>
Wed, 01 Jul 2009 21:50:20 +0900
Hello,

String literal in perl module file is something weird.
What's wrong? 

cp932 is standard code page of Japanese MS Windows.
Both pl and pm file are utf-8 encoded. utf-8 pragma is on.

Any help is very appreciated.


thanks,



C:\Users\yu-ji\work\literal> perl literal.pl
main日本語
utf8 flagged
LiteralTest日本語

C:\Users\yu-ji\work\literal> perlapp  --clean --force --nologo literal.pl

C:\Users\yu-ji\work\literal> literal.exe
main日本語
utf8 flagged
"\x{0097}" does not map to cp932 at /<C:\Users\yu-ji\work\literal\literal.exe>LiteralTest.pm line 18.
"\x{009c}" does not map to cp932 at /<C:\Users\yu-ji\work\literal\literal.exe>LiteralTest.pm line 18.
"\x{009e}" does not map to cp932 at /<C:\Users\yu-ji\work\literal\literal.exe>LiteralTest.pm line 18.
LiteralTesta\x{0097}\a\x{009c}¬ea\x{009e}



-- >8 -- literal.pl
#!perl
# -*- mode: cperl; coding: utf-8-dos; -*-

use 5.010;
use utf8;
use strict;
use warnings;

use Encode;
use Encode::JP;

use LiteralTest;

use open ':encoding(cp932)';
use open ':std';

say __PACKAGE__ . '日本語';

LiteralTest::say_literal();
-- >8 --



-- >8 -- LiteralTest.pm
# -*- mode: cperl; coding: utf-8-dos; -*-
package LiteralTest;

use 5.010;
use utf8;
use strict;
use warnings;

use Encode;

use Exporter 'import';
our @EXPORT_OK = qw( say_literal );

sub say_literal {
    my $nihongo = '日本語';

    say 'utf8 ' . ( Encode::is_utf8($nihongo) ? 'flagged' : 'not flagged' );
    say __PACKAGE__ .  $nihongo;

    # this shows correct string
    #say __PACKAGE__ .  decode('utf8', $nihongo);
    return;
}

1;
-- >8 --



C:\Users\yu-ji\work\literal> ver

Microsoft Windows XP [Version 5.1.2600]

C:\Users\yu-ji\work\literal> chcp
現在のコード ページ: 932

C:\Users\yu-ji\work\literal> perl -v

This is perl, v5.10.0 built for MSWin32-x86-multi-thread
(with 9 registered patches, see perl -V for more detail)

Copyright 1987-2007, Larry Wall

Binary build 1005 [290470] provided by ActiveState http://www.ActiveState.com
Built May 24 2009 12:17:36

-- snip --

C:\Users\yu-ji\work\literal> perlapp --version
PerlApp 8.0.1 build 289861
Copyright (C) 1998-2009 ActiveState Software Inc. All rights reserved.

-- snip --
Recent Messages in this Thread
Yu-ji Hosokawa Jul 01, 2009 12:50 pm
Yu-ji Hosokawa Jul 02, 2009 06:50 pm
Yu-ji Hosokawa Feb 05, 2010 04:14 pm
Messages in this thread