all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Coding system to encode arguments to groff?
Date: Sun, 03 Oct 2021 18:14:00 +0300	[thread overview]
Message-ID: <83fsti87k7.fsf@gnu.org> (raw)
In-Reply-To: <87bl469roj.fsf@vagabond.tim-landscheidt.de> (message from Tim Landscheidt on Sun, 03 Oct 2021 13:14:04 +0000)

> From: Tim Landscheidt <tim@tim-landscheidt.de>
> Cc: help-gnu-emacs@gnu.org
> Date: Sun, 03 Oct 2021 13:14:04 +0000
> 
> | (let
> |     ((temp-ps-buffer (generate-new-buffer "*test ps*"))
> |      (test-arg "a-o"))
> |   (with-temp-buffer
> |     (insert ".fam H\n\\*[test-arg]\n")
> |     (call-process-region
> |      (point-min)
> |      (point-max)
> |      "groff"
> |      nil
> |      temp-ps-buffer
> |      nil
> |      "-Tps"
> |      "-d" (concat "test-arg=" test-arg)))
> |   (switch-to-buffer temp-ps-buffer)
> |   (ps-mode)
> |   (doc-view-mode))
> 
> produces a PostScript buffer with the text "a-o".
> 
> With test-arg = "ä-ö" (ä minus ö), it produces gibberish mi-
> nus gibberish.
> 
> With test-arg = (encode-coding-string "ä-ö" 'iso-latin-1) (ä
> minus ö), it produces the text "ä-ö".
> 
> With test-arg = (encode-coding-string "ä–ö" 'iso-latin-1) (ä
> endash ö), it produces the text "ä[white space]ö".
> 
> With test-arg = (shell-command-to-string (concat "preconv -r
> <(echo " (shell-quote-argument "ä–ö") ")")) (ä endash ö), it
> produces the intended text "ä–ö".

So the problem is that troff doesn't accept non-ASCII command-line
arguments, and so you want to convert non-ASCII characters into a
series of characters encoded in the [\uNNNN] form, is that right?

Then I guess mapconcat is your friend, something like

  (mapconcat (lambda (ch)
	       (format "[\\u%4.4X]" ch))
	     "ä–ö" "")

There's no need to use preconv at all, as Emacs can do that by itself.
And this isn't an encoding, because codepoints are not encoded in any
sense of that word.



      reply	other threads:[~2021-10-03 15:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-29  8:01 Coding system to encode arguments to groff? Tim Landscheidt
2021-09-29 12:02 ` Eli Zaretskii
2021-10-03 13:14   ` Tim Landscheidt
2021-10-03 15:14     ` Eli Zaretskii [this message]

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

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

  git send-email \
    --in-reply-to=83fsti87k7.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=help-gnu-emacs@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.