Both of those hacks will fail on Windows or if a decoding error occurs.
In reply to Re^4: Counting bytes in a Unicode document by ikegami in thread Counting bytes in a Unicode document by jwkrahn