[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: string-bytes and coding systems

From: Eli Zaretskii
Subject: Re: string-bytes and coding systems
Date: Thu, 09 Mar 2017 18:01:37 +0200

> From: Eric Abrahamsen <>
> 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


> 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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]