help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: string-bytes and coding systems


From: Eric Abrahamsen
Subject: Re: string-bytes and coding systems
Date: Thu, 09 Mar 2017 09:35:24 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

>> 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.

Good to know.

>> 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.

I'll look into that. Thank you!

Eric




reply via email to

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