Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 487023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:33:46+00:00 2026-05-13T01:33:46+00:00

Before posting my question to the ActiveState forum, I’d like to try luck here

  • 0

Before posting my question to the ActiveState forum, I’d like to try luck here 🙂

I’m trying to convert a simple script of mine to .exe file using Perlapp (version 8.1). The Perl script works fine and it seems Perlapp also did its job successfully.
But the converted .exe file has some weird behavior, which, I believe, must be related to utf-8 encoding. For example, the Perl script would yield the result like:

hàn    huáng  zhòng  sè     sī     qīng   guó 

But running the executable file would give me only this:

h      hu     zh     s      s      q      gu

I’ve already configured Perlapp so that utf8.pm is explicitly added but the problem just refuses to go away. I’ve tried something else. For example,

binmode DATA, ":utf8"; 

and

">:encoding(utf8)"

but without any luck;

Can anyone kindly give me some hint as to what might be the reason? Thanks like always 🙂

I can post the whole code here but it seems unnecessary so I just paste some snippets of the code that I think is relevant to the problem:

use utf8;

%zidian = map {chomp;split/\s+/,$_,2} <DATA>;

open my $in,'<:utf8',"./original.txt";
open my $out,'>:utf8',"./modified.txt";

if ( $code~~%zidian) {
           $value = lc$zidian{$code};
}

__DATA__
3400    Qiū
3401    TIǎN
3404    KUà
3405    Wǔ

And one more thing, I’m running ActivePerl 5.10.0.on Windows XP (Chinese Version) and the script is saved as utf-8 encoding without BOM. PerlApp cannot handle a script that has BOM.

Edit

If I were to give a workable snippet, then I suppose it’s like giving the whole code because I’m using three inter-connected sub-routines, which I take with some modifications from Lingua::han::Pinyin module and Lingua::han::Utils module.

#! perl
# to make good vertical alignment,
# set font family to SonTi and font size to Four(12pts)
use utf8;


sub Unihan {
    my $hanzi = shift;
    my @unihan = map { uc sprintf("%x",$_) } unpack ("U*", $hanzi);
    }

sub csplit {
    my $hanzi = shift;
    my @return_hanzi;
    my @code = Unihan($hanzi);
    foreach my $code (@code) {
        my $value = pack("U*", hex $code);
        push @return_hanzi, $value if ($value);
    }
    return wantarray ? @return_hanzi : join( '', @return_hanzi );
    }

%zidian = map {chomp;split/\s+/,$_,2} <DATA>;

sub han2pinyin {
    my $hanzi = shift;
    my @pinyin;
    my @code = Unihan($hanzi);
     foreach $code (@code) {
           if ( $code~~%zidian) {
           $value = lc$zidian{$code};
        }
        else {
            $value = " ";
        }
        push @pinyin, $value;
    }
    return wantarray ? @pinyin : join( '', @pinyin );
}

open $in,'<:utf8',"./original.txt";
seek $in, 3,0;
open $out,'>:utf8',"./modified.txt";

while(<$in>){
     s/(.{18})/$1\n/g;
     push @tmp, $_;
}

foreach (@tmp){
my @hanzi;
my @pinyin;
@hanzi = csplit($_);
my $hang = join "", @hanzi;
@pinyin = han2pinyin($hang);

for ( my $i = 0; $i < @hanzi && $i < @pinyin; ++$i ) {
           if ( $hanzi[$i] =~ /[\xEFBC8C]|[\xE38082]|[\xEFBC81]|[\xEFBC9F]|[\xE2809C]|[\xE2809D]|[\xEFBC9A]/ ) {
            splice(@pinyin, $i, 0," ");
        }
       }

printf $out "%-7s" x @pinyin, @pinyin;
print $out "\n";
printf $out "%-6s" x @hanzi, @hanzi;
print $out "\n";
}


__DATA__
    3400    Qiū
    3401    TIǎN
    3404    KUà
    3405    Wǔ
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T01:33:46+00:00Added an answer on May 13, 2026 at 1:33 am

    ActiveState hasn’t given me any help yet. Whatever. Now I’ve figured out a workaround for my problem and this workaround looks very weird.

    First I added some otherwise useless utf-8 encoded characters to my DATA section, like the following:

    __DATA__
    aardvark 'ɑ:dvɑ:k
    aardwolf 'ɑ:dwulf
    aasvogel 'ɑ:sfәugәl
    3400    Qiū
    3401    TIǎN
    3404    KUà
    3405    Wǔ
    

    And then I removed the use utf8; pragma from my script;
    and then I removed the utf8 flag from the following line of code:

    open $out,'>:utf8',"./modified.txt";
    

    Now it becomes

    open $out,'>',"./modified.txt";
    

    But I had to let the following line of code unchanged:

    open $in,'<:utf8',"./original.txt";
    

    Then everything was okay except that I’d receive “wide characters in print” warnings. But I added another line of code:

    no warnings;
    

    And then I Perlapped my script and everything worked fine 🙂

    This is really strange. I’m suspecting this problem is somehow OS specific. It’s also quite likely that there’s something wrong with my Windows system. And I also tried Perl2exe and the compiled executable gave me some “memory 0010c4 cannot be read” error. Whatever. My problem is somehow fixed by myself 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Before posting my question, I would like to tell you that I have no
NOTE : Right before posting this question it occurred to me there's a better
I searched StackOverflow before posting this question but I wasn't able to find the
Before you all get pissy about me posting this question again, let me explain
Ok, I hope I've got everything listed up nicely before posting this question because
I have seen the following links before posting this question http://www.devx.com/wireless/Article/40792/1954 Saving Android Activity
before posting the question i did my research for 10 days so really hope
I did scour the net and stackoverflow before posting this question, so forgive me
I did check those posts about Infinite gallery before posting this question but it
The code below is trying to lazy login to Facebook right before posting a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.