GNU bug report logs - #20258
24.5; format-time-string miscounting of multibyte characters

Previous Next

Package: emacs;

Reported by: Gunnar Horrigmo <gunnar.horrigmo <at> usit.uio.no>

Date: Sat, 4 Apr 2015 15:36:01 UTC

Severity: minor

Tags: fixed, patch

Found in version 24.5

Fixed in version 27.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 20258 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Gunnar Horrigmo <gunnar.horrigmo <at> usit.uio.no>
Cc: 20258 <at> debbugs.gnu.org
Subject: Re: bug#20258: 24.5;
 format-time-string miscounting of multibyte characters
Date: Sat, 04 Apr 2015 18:42:13 +0300
> From: Gunnar Horrigmo <gunnar.horrigmo <at> usit.uio.no>
> Date: Sat, 04 Apr 2015 16:33:50 +0200
> 
> 
> As the subject says, format-time-string miscounts multibyte characters.
> Simple example with nb_NO.utf8 locale, where ø is two bytes:
> 
> (format-time-string "%6a" (date-to-time "Sat Apr  4 16:14:40 2015"))
> "  lø."
> 
> (length (format-time-string "%6a" (date-to-time "Sat Apr  4 16:14:40 2015")))
> 5

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

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






This bug report was last modified 5 years and 235 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.