🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
1 messages
1 total messages Started by Eli the Bearded Fri, 02 Mar 2018 01:53
UTF-8 "fix" for trn4-77
#262594
Author: Eli the Bearded
Date: Fri, 02 Mar 2018 01:53
41 lines
2850 bytes
I've got a utf-8 clean display environment, but reading news in trn with
utf-8 characters in them would sometimes show mangled characters. I
guessed that trn was trampling the high-bit on iso-8859-1 high-bit
control characters (0x80 to 0x9F) and did nothing for a long time.

Then I noticed that there is a switch:

       -j   forces trn to leave control characters unmolested in
            messages.

And testing that, I found that it worked to stop the utf-8 breakage.
Of course, it leaves control characters "unmolested" which is not
necessarily ideal.

This one line change, however, will "properly" defang control characters
(0x01 -> "^A", etc) while not brutalizing the high-bit stuff used by
UTF-8:

--- trn-4.0-test77/art.c.orig   2010-09-02 02:12:26.000000000 -0400
+++ trn-4.0-test77/art.c        2018-03-01 20:15:59.000000000 -0500
@ -468,7 +468,7 @@
                        outpos += 2;
                    }
                    else {              /* other control char */
-                       if (dont_filter_control) {
+                       if (dont_filter_control || (*bufptr & 0x80)) {
                            if (outputok)
                                putchar(*bufptr);
                            outpos++;

As should be clear, this does absolutely no good for you if your
environment is not utf-8 clean or if you are reading posts that are not
in utf-8.

What a tangled mess it is in artio.c (reading the article in) / art.c
(displaying the article to the user). I would not envy someone trying to
put a real character set conversion in.

Elijah
------
not sure if there is still a working trn mailing list
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads