unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* string-bytes and coding systems
@ 2017-03-08 23:17 Eric Abrahamsen
  2017-03-09  7:46 ` hector
  2017-03-09 16:01 ` Eli Zaretskii
  0 siblings, 2 replies; 16+ messages in thread
From: Eric Abrahamsen @ 2017-03-08 23:17 UTC (permalink / raw)
  To: help-gnu-emacs

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




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

end of thread, other threads:[~2017-03-10 19:10 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).