Edwin: force subprocess I/O ports to use iso-8859-1 coding.
authorChris Hanson <org/chris-hanson/cph>
Fri, 19 Jul 2019 03:26:56 +0000 (23:26 -0400)
committerChris Hanson <org/chris-hanson/cph>
Fri, 19 Jul 2019 03:32:11 +0000 (23:32 -0400)
There may still be a problem with synchronous subprocesses, since we don't have
a way to get at those ports.  If the process writes UTF-8, then the I/O copier
will try to write unicode chars to a buffer, and I'm not sure what will happen
in that case.  It might just ignore the upper bits.

src/edwin/process.scm

index 1c2d8f835787f7f07008c9ffb9f044f5e53a8b27..71d0fe7b051162f3ff8ab1b672a7b0b08ff38635 100644 (file)
@@ -159,6 +159,12 @@ Initialized from the SHELL environment variable."
           (let ((channel (subprocess-input-channel subprocess)))
             (if channel
                 (channel-nonblocking channel)))
+           (let ((fix-port
+                  (lambda (port)
+                    (if (and port (port/supports-coding? port))
+                        (port/set-coding port 'iso-8859-1)))))
+             (fix-port (subprocess-input-port subprocess))
+             (fix-port (subprocess-output-port subprocess)))
           (set-process-status-registration!
            process
            (register-subprocess-event