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

  • Home
  • SEARCH
  • 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 8536433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:39:46+00:00 2026-06-11T10:39:46+00:00

Documentation all directs me to unicode support, yet I don’t think my request has

  • 0

Documentation all directs me to unicode support, yet I don’t think my request has anything to do with Unicode. I want to work with raw bytes within the context of a single scalar; I need to be able to figure out its length (in bytes), take substrings of it (in bytes), write the bytes to disc, and over the network. Is there an easy way to do this, without treating the bytes as any sort of encoding in perl?

EDIT

More explicitly,

my $data = "Perl String, unsure of encoding and don't need to know";
my @data_chunked_into_1024_bytes_each = #???
  • 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-06-11T10:39:47+00:00Added an answer on June 11, 2026 at 10:39 am

    Perl strings are, conceptually, strings of characters, which are positive 32-bit integers that (normally) represent Unicode code points. A byte string, in Perl, is just a string in which all the characters have values less than 256.

    (That’s the conceptual view. The internal representation is somewhat more complicated, as the perl interpreter tries to store byte strings — in the above sense — as actual byte strings, while using a generalized UTF-8 encoding for strings that contain character values of 256 or higher. But this is all supposed to be transparent to the user, and in fact mostly is, except for some ugly historical corner cases like the bitwise not (~) operator.)

    As for how to turn a general string into a byte string, that really depends on what the string you have contains and what the byte string is supposed to contain:

    • If your string already is a string of bytes — e.g. if you read it from a file in binary mode — then you don’t need to do anything. The string shouldn’t contain any characters above 255 to being with, and if it does, that’s an error and will probably be reported as such by the encryption code.

    • Similarly, if your string is supposed to encode text in the ASCII or ISO-8859-1 encodings (which encode the 7- and 8-bit subsets of Unicode respectively), then you don’t need to do anything: any characters up to 255 are already correctly encoded, and any higher values are invalid for those encodings.

    • If your input string contains (Unicode) text that you want to encode in some other encoding, then you’ll need to convert the string to that encoding. The usual way to do that is by using the Encode module, like this:

      use Encode;
      my $byte_string = encode( "name of encoding", $text_string );
      

      Obviously, you can convert the byte string back to the corresponding character string with:

      use Encode;
      my $text_string = decode( "name of encoding", $byte_string );
      
    • For the special case of the UTF-8 encoding, it’s also possible to use the built-in utf8::encode() function instead of Encode::encode():

      utf8::encode( $string );
      

      which does essentially the same thing as:

      use Encode;
      $string = encode( "utf8", $string );
      

      Note that, unlike Encode::encode(), the utf8::encode() function modifies the input string directly. Also note that the "utf8" above refers to Perl’s extended UTF-8 encoding, which allows values outside the official Unicode range; for strictly standards-compliant UTF-8 encoding, use "utf-8" with a hyphen (see Encode documentation for the gory details). And, yes, there’s also a utf8::decode() function that does pretty much what you’d expect.

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

Sidebar

Related Questions

I've reviewed all the documentation and Google results surrounding this and I think I
I read all of Microsoft's documentation but their claim is that it should work
Adobe Flash CS4 contains no documentation at all; it simply redirects to the online
As the Beautiful Soup documentation says: If all else fails, the license for Beautiful
I have read the documentation and searched all over but I can't find how
I have read all the documentation I found on how to integrate Unity3D projects
February, 26 2010 21:34:00 Based on all the documentation I can find, MMMM, d
All links in produced documentation are like: docs/classes/db_Foo/Bar.html . The actual filenames do not
I scanned all the java documentation on the synchronized statements looking for an answer
After reading all sorts of Stackoverflow postings and various documentation including some on http://code.google.com/p/google-api-java-client/

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.