all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: string-bytes and coding systems
Date: Thu, 09 Mar 2017 18:01:37 +0200	[thread overview]
Message-ID: <83tw72fnha.fsf@gnu.org> (raw)
In-Reply-To: <87r327nyto.fsf@ericabrahamsen.net> (message from Eric Abrahamsen on Wed, 08 Mar 2017 15:17:07 -0800)

> From: Eric Abrahamsen <eric@ericabrahamsen.net>
> Date: Wed, 08 Mar 2017 15:17:07 -0800
> 
> I'm essentially taking the `string-bytes' of each line, and if it's too
> long, popping characters off the end until it's fewer than 75 bytes.
> 
> My understanding/assumption is that `string-bytes' returns the number of
> bytes according to Emacs' internal coding system

Yes.

> which is close enough to utf-8 to make no difference.

No.  The deviations from UTF-8 could be significant in some cases,
with some exotic characters and with raw bytes.

> When this text gets written to file it will also be encoded as
> utf-8, ergo testing string lengths with `string-bytes' is going to
> always produce the right results in the final file.

I suggest to use filepos-to-bufferpos to find where to break text into
lines.



  parent reply	other threads:[~2017-03-09 16:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-08 23:17 string-bytes and coding systems Eric Abrahamsen
2017-03-09  7:46 ` hector
2017-03-09  7:54   ` Yuri Khan
2017-03-09  9:23     ` hector
2017-03-09 17:36       ` Eric Abrahamsen
2017-03-10  4:39         ` Thien-Thi Nguyen
2017-03-10  6:36           ` Eric Abrahamsen
2017-03-10  4:59         ` Alexis
2017-03-10  6:10           ` Eric Abrahamsen
2017-03-09 16:01 ` Eli Zaretskii [this message]
2017-03-09 17:35   ` Eric Abrahamsen
2017-03-10  9:02   ` Stefan Monnier
2017-03-10 16:37     ` Eric Abrahamsen
2017-03-10 18:26       ` Stefan Monnier
2017-03-10 18:56         ` Eric Abrahamsen
2017-03-10 19:10           ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83tw72fnha.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.