all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to use string-to/as-unibyte correctly?
@ 2016-06-20 23:40 Leo Liu
  2016-06-21  0:56 ` Stefan Monnier
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Leo Liu @ 2016-06-20 23:40 UTC (permalink / raw)
  To: emacs-devel

Hi List,

As part of discussion on bug http://debbugs.gnu.org/23750, I am
wondering what is the deal with string-to/as-unibyte? How to use them
correctly or are they in their way out (obsolete)? Thanks.

,----[ Eli Zaretskii ]
| neither string-to-unibyte not string-as-unibyte should ever be used in
| applications, their use is more often than not a sign of some basic
| misunderstanding of text encoding.
`----

,----[ Eli Zaretskii ]
| Bottom line: like I said, there should be no reason to use
| string-*-unibyte in modern Emacs code on the url-http level or higher
| (maybe not at all). Its use is a sign of some basic misunderstanding,
| or a bug elsewhere, or remnant of old problems that no longer exist.
| So I think we should reconsider the solution on master as well.
`----

Leo




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

* Re: How to use string-to/as-unibyte correctly?
  2016-06-20 23:40 How to use string-to/as-unibyte correctly? Leo Liu
@ 2016-06-21  0:56 ` Stefan Monnier
  2016-06-22  3:33   ` Leo Liu
  2016-06-21  2:36 ` Eli Zaretskii
  2016-06-26  2:01 ` Leo Liu
  2 siblings, 1 reply; 10+ messages in thread
From: Stefan Monnier @ 2016-06-21  0:56 UTC (permalink / raw)
  To: emacs-devel

> As part of discussion on bug http://debbugs.gnu.org/23750, I am
> wondering what is the deal with string-to/as-unibyte? How to use them
> correctly or are they in their way out (obsolete)? Thanks.

The correct way to use them is to not use them and use
encode/decode-coding-string instead.


        Stefan




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

* Re: How to use string-to/as-unibyte correctly?
  2016-06-20 23:40 How to use string-to/as-unibyte correctly? Leo Liu
  2016-06-21  0:56 ` Stefan Monnier
@ 2016-06-21  2:36 ` Eli Zaretskii
  2016-06-26  2:01 ` Leo Liu
  2 siblings, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2016-06-21  2:36 UTC (permalink / raw)
  To: Leo Liu; +Cc: emacs-devel

> From: Leo Liu <sdl.web@gmail.com>
> Date: Tue, 21 Jun 2016 07:40:31 +0800
> 
> As part of discussion on bug http://debbugs.gnu.org/23750, I am
> wondering what is the deal with string-to/as-unibyte? How to use them
> correctly or are they in their way out (obsolete)?

Don't use them, period.  They are remnants from the era long gone,
before Emacs used Unicode and UTF-8 as the basis for its internal
representation of characters.  Nowadays the only place where such
conversions are sometimes needed are on the C level, deep within Emacs
internals.  Applications should never use them.

I'm okay with declaring them obsolete, if it helps.



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

* Re: How to use string-to/as-unibyte correctly?
  2016-06-21  0:56 ` Stefan Monnier
@ 2016-06-22  3:33   ` Leo Liu
  2016-06-22  7:49     ` Andreas Schwab
  2016-06-22 14:59     ` Eli Zaretskii
  0 siblings, 2 replies; 10+ messages in thread
From: Leo Liu @ 2016-06-22  3:33 UTC (permalink / raw)
  To: emacs-devel

On 2016-06-20 20:56 -0400, Stefan Monnier wrote:
[snipped 4 lines]
> The correct way to use them is to not use them and use
> encode/decode-coding-string instead.
>
>
>         Stefan

On 2016-06-21 05:36 +0300, Eli Zaretskii wrote:
[snipped 7 lines]
> Don't use them, period.  They are remnants from the era long gone,
> before Emacs used Unicode and UTF-8 as the basis for its internal
> representation of characters.  Nowadays the only place where such
> conversions are sometimes needed are on the C level, deep within Emacs
> internals.  Applications should never use them.
>
> I'm okay with declaring them obsolete, if it helps.

I had two cases of string-to-unibyte to mean I am expecting unibyte
string and will complain if given something else.

Looks like we'd better start the process of phasing out these functions
so that nobody will make the mistake of using them.

Leo




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

* Re: How to use string-to/as-unibyte correctly?
  2016-06-22  3:33   ` Leo Liu
@ 2016-06-22  7:49     ` Andreas Schwab
  2016-06-26  2:02       ` Leo Liu
  2016-06-22 14:59     ` Eli Zaretskii
  1 sibling, 1 reply; 10+ messages in thread
From: Andreas Schwab @ 2016-06-22  7:49 UTC (permalink / raw)
  To: Leo Liu; +Cc: emacs-devel

Leo Liu <sdl.web@gmail.com> writes:

> I had two cases of string-to-unibyte to mean I am expecting unibyte
> string and will complain if given something else.

There should be very few places that need a unibyte string.  Basically
only where we are communicating with outside of Emacs, immediately
before decoding or after encoding the string.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."



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

* Re: How to use string-to/as-unibyte correctly?
  2016-06-22  3:33   ` Leo Liu
  2016-06-22  7:49     ` Andreas Schwab
@ 2016-06-22 14:59     ` Eli Zaretskii
  2016-06-25  1:57       ` Leo Liu
  1 sibling, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2016-06-22 14:59 UTC (permalink / raw)
  To: Leo Liu; +Cc: emacs-devel

> From: Leo Liu <sdl.web@gmail.com>
> Date: Wed, 22 Jun 2016 11:33:19 +0800
> 
> Looks like we'd better start the process of phasing out these functions
> so that nobody will make the mistake of using them.

You mean, deprecating them?  Patches to that effect are welcome.

Thanks.



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

* Re: How to use string-to/as-unibyte correctly?
  2016-06-22 14:59     ` Eli Zaretskii
@ 2016-06-25  1:57       ` Leo Liu
  2016-06-25  8:01         ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: Leo Liu @ 2016-06-25  1:57 UTC (permalink / raw)
  To: emacs-devel

On 2016-06-22 17:59 +0300, Eli Zaretskii wrote:
> You mean, deprecating them?  Patches to that effect are welcome.

Should we deprecate string-to/as-multibyte as well?

Leo




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

* Re: How to use string-to/as-unibyte correctly?
  2016-06-25  1:57       ` Leo Liu
@ 2016-06-25  8:01         ` Eli Zaretskii
  0 siblings, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2016-06-25  8:01 UTC (permalink / raw)
  To: Leo Liu; +Cc: emacs-devel

> From: Leo Liu <sdl.web@gmail.com>
> Date: Sat, 25 Jun 2016 09:57:31 +0800
> 
> On 2016-06-22 17:59 +0300, Eli Zaretskii wrote:
> > You mean, deprecating them?  Patches to that effect are welcome.
> 
> Should we deprecate string-to/as-multibyte as well?

Yes.



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

* Re: How to use string-to/as-unibyte correctly?
  2016-06-20 23:40 How to use string-to/as-unibyte correctly? Leo Liu
  2016-06-21  0:56 ` Stefan Monnier
  2016-06-21  2:36 ` Eli Zaretskii
@ 2016-06-26  2:01 ` Leo Liu
  2 siblings, 0 replies; 10+ messages in thread
From: Leo Liu @ 2016-06-26  2:01 UTC (permalink / raw)
  To: emacs-devel

Filed as http://debbugs.gnu.org/23850




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

* Re: How to use string-to/as-unibyte correctly?
  2016-06-22  7:49     ` Andreas Schwab
@ 2016-06-26  2:02       ` Leo Liu
  0 siblings, 0 replies; 10+ messages in thread
From: Leo Liu @ 2016-06-26  2:02 UTC (permalink / raw)
  To: emacs-devel

On 2016-06-22 09:49 +0200, Andreas Schwab wrote:
> There should be very few places that need a unibyte string.  Basically
> only where we are communicating with outside of Emacs, immediately
> before decoding or after encoding the string.

Thanks for the input.

Leo




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

end of thread, other threads:[~2016-06-26  2:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-20 23:40 How to use string-to/as-unibyte correctly? Leo Liu
2016-06-21  0:56 ` Stefan Monnier
2016-06-22  3:33   ` Leo Liu
2016-06-22  7:49     ` Andreas Schwab
2016-06-26  2:02       ` Leo Liu
2016-06-22 14:59     ` Eli Zaretskii
2016-06-25  1:57       ` Leo Liu
2016-06-25  8:01         ` Eli Zaretskii
2016-06-21  2:36 ` Eli Zaretskii
2016-06-26  2:01 ` Leo Liu

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.