Hi Ralph, Le jeudi 15 août 2013 à 12:55 +0100, Ralph Corderoy a écrit : > Hi Grégoire, > > > > troff takes ISO-8859-1 as its default input. If you want to feed it > > > UTF-8 then look at groff's -k option. Try > > > > > > printf 'testé\n' | groff -k -me -X > > > > thanks a lot for your answer. Your command works fine. I wondered > > where do you have this information from: > > I've picked it up from subscribing to this list and seeing others' > answers over time. :-)
Thank you, I will read more in http://lists.gnu.org/archive/html/groff/2013-08/threads.html if I find something I can use. > > > I was searching in man groff about the -k option, than in man preconv. > > I understood that -k make use of preconv, which can convert utf-8 to > > Latin1. > > Yes, they are the right places to read. GNU troff understands \[u1234] > for Unicode codepoint U+1234 and preconv produces these. > > > I can find out by myself with which caracters I will have to use "\n". > > But try this: > > > > printf 'testé\n, ü\nber, ç\na' | groff -k -me -X > > > > There is a space too much between é and , because of \n > > Is there a solution for that? > > That had me puzzled for a while but the penny has dropped. I wrote \n > not because it's needed for groff -k to handle the preceding character > but because printf(1), unlike echo(1), doesn't automatically add a > linefeed to its output and \n is the "escape" to do this. Try these to > see what I mean. > > printf 'foo\nbar\n' > printf 'testé\n, ü\nber, ç\na' > printf foo Yes, yes, if you use printf, you will need \n to have a new line. If you use gedit the -k option takes any special signs like é,à,è,ö,ü,ç, %,&,æ . It works fine. Only for € I didn't find a solution yet. OK, if you don't want to write about money, you have no problem :-) > > > I tried something myself: The following command is not the solution: > > printf 'testé\, ü\ber, ç\a' | groff -k -me -X > > This should work just fine. > > printf 'testé, über, ça\n' | groff -k -me -X > > > ... further I was reading around in the manual about groff -k and > > after which characters you have to use \n. I didn't found anything. > > \n does mean something to troff too, but the \n given to printf is > interpreted by printf and turned into a single byte, ASCII LF, value 10, > before troff gets to see it. \n in troff makes it interpolate the value > of the given numeric register. > > $ printf '.nr x 42\nNumbers: \\nx \\n(fo \\n[bar]\n' | > > groff -rfo=314 -rbar=281 -kX > > Again, do just the printf to see groff's input as if you had typed it in > a file. \\ is the escape to have printf produce a single \ > > Cheers, Ralph.