unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#17865: 24.3.92; encode-coding-string returns 1
@ 2014-06-27 17:30 Leo Liu
  2014-06-27 20:15 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Leo Liu @ 2014-06-27 17:30 UTC (permalink / raw)
  To: 17865


(with-temp-buffer
  (set-buffer-multibyte nil)
  (list (encode-coding-string "我" 'utf-8 nil (current-buffer))
        (buffer-string)))

In my emacs it inserts three bytes yet return just one. Bug?

Leo





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#17865: 24.3.92; encode-coding-string returns 1
  2014-06-27 17:30 bug#17865: 24.3.92; encode-coding-string returns 1 Leo Liu
@ 2014-06-27 20:15 ` Eli Zaretskii
  2014-06-27 23:56   ` Leo Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2014-06-27 20:15 UTC (permalink / raw)
  To: Leo Liu; +Cc: 17865

> From: Leo Liu <sdl.web@gmail.com>
> Date: Sat, 28 Jun 2014 01:30:54 +0800
> 
> 
> (with-temp-buffer
>   (set-buffer-multibyte nil)
>   (list (encode-coding-string "我" 'utf-8 nil (current-buffer))
>         (buffer-string)))
> 
> In my emacs it inserts three bytes yet return just one. Bug?

Not a bug: you inserted one character.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#17865: 24.3.92; encode-coding-string returns 1
  2014-06-27 20:15 ` Eli Zaretskii
@ 2014-06-27 23:56   ` Leo Liu
  2014-06-28  7:00     ` Eli Zaretskii
  2014-06-28  7:29     ` Andreas Schwab
  0 siblings, 2 replies; 5+ messages in thread
From: Leo Liu @ 2014-06-27 23:56 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 17865

On 2014-06-27 23:15 +0300, Eli Zaretskii wrote:
> Not a bug: you inserted one character.

But without `(set-buffer-multibyte nil)' you get 3. Normal?

Leo





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#17865: 24.3.92; encode-coding-string returns 1
  2014-06-27 23:56   ` Leo Liu
@ 2014-06-28  7:00     ` Eli Zaretskii
  2014-06-28  7:29     ` Andreas Schwab
  1 sibling, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2014-06-28  7:00 UTC (permalink / raw)
  To: Leo Liu; +Cc: 17865

> From:  Leo Liu <sdl.web@gmail.com>
> Cc: 17865@debbugs.gnu.org
> Date: Sat, 28 Jun 2014 07:56:53 +0800
> 
> On 2014-06-27 23:15 +0300, Eli Zaretskii wrote:
> > Not a bug: you inserted one character.
> 
> But without `(set-buffer-multibyte nil)' you get 3. Normal?

Yes, because then you insert 3 multibyte characters that represent 3
8-bit bytes.

The value you get counts characters produced by the encoding.  How to
count characters in a unibyte buffer is a question that has no easy
answers.

If, after all this, you will conclude that the return value is not
very useful for high-level programming, I will agree with you.  The
return value is set up to provide what some internal use cases need,
and that's it.  It just returns some member of the structure used to
convert the string; how that member is computed is an implementation
detail that rarely, if at all, is exposed to Lisp applications.

It could be that the return value of 1 in a unibyte buffer was never
bumped into before, and thus never scrutinized.  It could also be that
some Lisp application actually needs that value to be 1.

What is the real-life use case behind this?  Maybe if we talk in the
context of that use case, the discussion will be more meaningful.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#17865: 24.3.92; encode-coding-string returns 1
  2014-06-27 23:56   ` Leo Liu
  2014-06-28  7:00     ` Eli Zaretskii
@ 2014-06-28  7:29     ` Andreas Schwab
  1 sibling, 0 replies; 5+ messages in thread
From: Andreas Schwab @ 2014-06-28  7:29 UTC (permalink / raw)
  To: Leo Liu; +Cc: 17865-done

Fixed in emacs-24.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-28  7:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-27 17:30 bug#17865: 24.3.92; encode-coding-string returns 1 Leo Liu
2014-06-27 20:15 ` Eli Zaretskii
2014-06-27 23:56   ` Leo Liu
2014-06-28  7:00     ` Eli Zaretskii
2014-06-28  7:29     ` Andreas Schwab

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).