[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Coding system to encode arguments to groff?
From: |
Eli Zaretskii |
Subject: |
Re: Coding system to encode arguments to groff? |
Date: |
Wed, 29 Sep 2021 15:02:59 +0300 |
> From: Tim Landscheidt <tim@tim-landscheidt.de>
> Date: Wed, 29 Sep 2021 08:01:12 +0000
>
> I pass text arguments from Emacs Lisp to a groff command
> with the "-d" option. For ASCII strings, this is trivial;
> for strings with umlauts, I need to use:
>
> | (encode-coding-string variable-to-pass 'iso-latin-1)
What is your default locale's codeset on that system? In general, if
the default locale matches the encoding you need to use, the above
should happen automagically.
> For strings with other Unicode characters like "–" (#x2013),
> I need to call groff's preconv like:
>
> | (shell-command-to-string (concat "preconv -r <(echo " (shell-quote-argument
> variable-to-pass) ")"))
>
> which for "ä–ö" returns something like:
>
> | \[u00E4]\[u2013]\[u00F6]
This is just the original "ä–ö" string, so I'm not quite sure what did
the above accomplish.
> Now in Emacs, this looks very much like what a coding system
> would do. The info documentation for elisp just laconically
> says:
>
> | How to define a coding system is an arcane matter, and is not
> | documented here.
>
> Has someone implemented such a coding system for groff so
> that something like:
>
> | (encode-coding-string variable-to-pass 'x-groff)
I don't think you should need a new coding-system. But you didn't
explain why you need to explicitly encode the command-line arguments,
so it's hard to give an accurate advice. What kind of Groff command
needs this jumping through hoops from you? E.g., why isn't it enough
to bind coding-system-for-write to whatever you need, around the call
to call-process or whatever?
IOW, please describe in more detail the Groff-related context in which
this problem happens, so that we could have an intelligent discussion
of the issues you might have.