unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Miles Bader <miles@lsi.nec.co.jp>
Cc: emacs-devel@gnu.org
Subject: Re: yet more term.el fixes #2
Date: Wed, 22 Sep 2004 13:47:08 +0900	[thread overview]
Message-ID: <buor7ougbar.fsf@mctpc71.ucom.lsi.nec.co.jp> (raw)
In-Reply-To: <200409220418.i8M4IJGK005554@scanner2.ics.uci.edu> (Dan Nicolaescu's message of "Tue, 21 Sep 2004 21:18:16 -0700")

Dan Nicolaescu <dann@ics.uci.edu> writes:
> Looking closer, the characters > 158 decimal have char-width 4 in my
> setup. 
>
> Use this to print all the widths: 

Hmmm, using that code I get simular (odd) results:  the result of
`char-width' seems to be completely unrelated to the actual displayed
width of the characters -- some values are displayed as a single column
character, but have a `char-width' value of 4, and some are displayed as
a 4-column escape-sequence, but have a `char-width' value of 1!!

Here's a version that uses `decode-coding-string' to get correct
results; probably term.el should be using something like that:

   (defun print-width ()
     (interactive)
     (let ((i 0))
       (while (< i 256)
         (let ((decoded (decode-coding-string (string i) 'iso-8859-1)))
           (insert (format "%d %d %s\n" i (string-width decoded) decoded)))
         (setq i (1+ i)))))

Using this, all the char-width values match the displayed representation.

When simply inserting raw character values in to the buffer, it seems
that some sort of default decoding takes place at insert/display time,
but an equivalent default decoding is not done by `char-width'; whether
that represents a bug, and if so, where, I don't know, but I think it's
probably always safer to be explicit as in the above code.

-Miles
-- 
The secret to creativity is knowing how to hide your sources.
  --Albert Einstein

  reply	other threads:[~2004-09-22  4:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-22  3:17 yet more term.el fixes #2 Dan Nicolaescu
2004-09-22  3:42 ` Miles Bader
2004-09-22  4:18   ` Dan Nicolaescu
2004-09-22  4:47     ` Miles Bader [this message]
2004-09-22 13:16       ` Stefan Monnier
2004-09-22 17:43         ` Dan Nicolaescu
2004-09-22 20:23           ` Stefan Monnier
2004-09-23  2:14             ` Dan Nicolaescu
2004-09-23 11:44               ` Stefan
2004-09-23 21:28                 ` 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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=buor7ougbar.fsf@mctpc71.ucom.lsi.nec.co.jp \
    --to=miles@lsi.nec.co.jp \
    --cc=emacs-devel@gnu.org \
    --cc=miles@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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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