[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#20258: 24.5; format-time-string miscounting of multibyte characters
From: |
Stefan Monnier |
Subject: |
bug#20258: 24.5; format-time-string miscounting of multibyte characters |
Date: |
Sat, 04 Apr 2015 12:03:47 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
> '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