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

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

string-bytes and coding systems


From: Eric Abrahamsen
Subject: string-bytes and coding systems
Date: Wed, 08 Mar 2017 15:17:07 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

I'm writing a function that's supposed to wrap too-long text lines; the
RFC says anything over 75 octets (excluding eol) needs to be wrapped,
but multibyte characters must not be split.

Everything seems to be working fine, but I want to make sure I'm not
making any dangerous assumptions about `string-bytes' and encoding.

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

Have I understood things correctly?

Thanks!
Eric




reply via email to

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