in reply to Re^8: Counting bytes in a Unicode document
in thread Counting bytes in a Unicode document

Ysth and I referenced bytes and showed code to get the byte length of a Unicode string

You replied

> Both of those hacks will fail on Windows

Now you are talking about not passing a file ...???

Either bytes::length() works on Windows or it's buggy and the documentation should be fixed.

Updates

In hindsight, what you probably tried to say is that the OP had a problem with successfully reading the file on Windows.

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^10: Counting bytes in a Unicode document
by ysth (Canon) on Oct 10, 2024 at 22:08 UTC
    I think the concern ikegami had is that the string will have crlf as two bytes where the file only had one.
    --
    A math joke: r = | |csc(θ)|+|sec(θ)| |-| |csc(θ)|-|sec(θ)| |

      And encoding errors are replaced with U+FFFD, which may have a different length than the original.

Re^10: Counting bytes in a Unicode document
by ikegami (Patriarch) on Oct 10, 2024 at 15:55 UTC

    There's nothing sudden about mentioning files. You seem to have forgotten the question is about the length of a file?

    So I repeat: Your "solution" of counting the bytes used to store the decoded file isn't always going to be correct.

    In hindsight, what you probably tried to say is that the OP had a problem with successfully reading the file on Windows.

    No. I clearly said it's your hack that will fail.