Subject: bug#20258: 24.5; format-time-string miscounting of multibyte characters

From: Stefan Monnier <[email-masked]>
Date: Sat, 04 Apr 2015 12:03:47 -0400

> 'length' counts characters, not bytes.  If you need to count bytes,
> use 'string-bytes' instead:

>   (string-bytes "  lø.") => 6

And in 99% of the cases, using length-bytes doesn't do what you think
(it doesn't count the number of bytes that it would take in your
favorite coding-system, but the number of bytes it takes within Emacs's
internal encoding).
If you want to know how many bytes it would take in your locale's
encoding, then you need:

   (length (encode-coding-string <thestring> locale-coding-system))

        Stefan