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 1928898
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T07:03:26+00:00 2026-05-17T07:03:26+00:00

I have an external module, that is returning me some strings. I am not

  • 0

I have an external module, that is returning me some strings. I am not sure how are the strings returned, exactly. I don’t really know, how Unicode strings work and why.

The module should return, for example, the Czech word “být”, meaning “to be”. (If you cannot see the second letter – it should look like this.) If I display the string, returned by the module, with Data Dumper, I see it as b\x{fd}t.

However, if I try to print it with print $s, I got “Wide character in print” warning, and ? instead of ý.

If I try Encode::decode(whatever, $s);, the resulting string cannot be printed anyway (always with the “Wide character” warning, sometimes with mangled characters, sometimes right), no matter what I put in whatever.

If I try Encode::encode("utf-8", $s);, the resulting string CAN be printed without the problems or error message.

If I use use encoding 'utf8';, printing works without any need of encoding/decoding. However, if I use IO::CaptureOutput or Capture::Tiny module, it starts shouting “Wide character” again.

I have a few questions, mostly about what exactly happens. (I tried to read perldocs, but I was not very wise from them)

  1. Why can’t I print the string right after getting it from the module?
  2. Why can’t I print the string, decoded by “decode”? What exactly “decode” did?
  3. What exactly “encode” did, and why there was no problem in printing it after encoding?
  4. What exactly use encoding do? Why is the default encoding different from utf-8?
  5. What do I have to do, if I want to print the scalars without any problems, even when I want to use one of the capturing modules?

edit: Some people tell me to use -C or binmode or PERL_UNICODE. That is a great advice. However, somehow, both the capturing modules magically destroy the UTF8-ness of STDOUT. That seems to be more a bug of the modules, but I am not really sure.

edit2: OK, the best solution was to dump the modules and write the “capturing” myself (with much less flexibility).

  • 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-17T07:03:29+00:00Added an answer on May 17, 2026 at 7:03 am
    1. Because you output a string in perl’s internal form (utf8) to a non-unicode filehandle.
    2. The decode function decodes a sequence of bytes assumed to be in ENCODING into Perl’s internal form (utf8). Your input seems to be already decoded,
    3. The encode() function encodes a string from Perl’s internal form into ENCODING.
    4. The encoding pragma allows you to write your script in any encoding you like. String literals are automatically converted to perl’s internal form.
    5. Make sure perl knows which encoding your data comes in and come out.

    See also perluniintro, perlunicode, Encode module, binmode() function.

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

Sidebar

Related Questions

No related questions found

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.