Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: truncate string to byte count

by LanX (Cardinal)
on Feb 28, 2019 at 11:50 UTC ( #1230667=note: print w/replies, xml ) Need Help??


in reply to Re: truncate string to byte count
in thread truncate string to byte count

> I don't understand why is this such a huge problem?

The (text-)string commands in Perl operate on a character and not byte basis. A string carries an internal utf8 flag which determines how it's handled.

Saying so, some commands like unpack or vec are supposed to operate on raw bit vectors and might be useful here.

*) i.e. variable byte length character

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1230667]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2021-03-01 22:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favorite kind of desktop background is:











    Results (27 votes). Check out past polls.

    Notices?