Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^4: How to reverse a (Unicode) string

by moritz (Cardinal)
on Jan 10, 2008 at 08:33 UTC ( #661571=note: print w/replies, xml ) Need Help??

in reply to Re^3: How to reverse a (Unicode) string
in thread How to reverse a (Unicode) string

I hesitated before writing about the byte level, but S02 explictly mentions it:

You can also ask for the total string length of an array's elements, in bytes, codepoints or graphemes, using these methods .bytes, .codes or .graphs respectively on the array. The same methods apply to strings as well.

And of course you have a byte level if you specify an encoding, or if there is a default one. Just like you can have a language dependent notion of a grapheme if you pick a language.

But I think the spec should be a bit clearer regarding how the character encoding is chosen.

Replies are listed 'Best First'.
Re^5: How to reverse a (Unicode) string
by Juerd (Abbot) on Jan 10, 2008 at 21:42 UTC

    The way I expect it to work, is that Unicode strings don't get encodings, but byte buffers and I/O handles do. If you give a Buf an encoding, you can treat it as a Str, as long as the encoding is consistent. Using a real Str may perform much better, because Perl 6 can encode it internally however it wishes, and can make many more assumptions (for optimization purposes).

    Giving a Unicode string an "encoding" property is the wrong way around, but it can take quite some time and experience before one realises that.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2020-10-01 13:44 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (13 votes). Check out past polls.