Pipe vs TCPSocket on Windows

I recently moved Maxima.jl over to Pipe based communication from TCPSocket based communication and started getting Unicode errors. The communication layer sends messages back and forth between Julia and Maxima. Oddly, the Pipe implementation can’t deal with Unicode character on Windows. Does the Pipe somehow change the encoding of strings on Windows?

Here is some (unfortunately not very minimal) example code:

julia> input = Pipe();

julia> output = Pipe();

julia> proc = spawn(`maxima.bat -l sbcl`, (input, output, STDERR))
Process(`maxima.bat -l sbcl`, ProcessRunning)

julia> readavailable(output) |> String |> print
Maxima 5.39.0_2_g5a49f11_dirty http://maxima.sourceforge.net
using Lisp SBCL 1.3.12
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1)
julia> write(input, "1 + 1;")
6

julia> readavailable(output) |> String |> print

(%o1)                                  2
(%i2)
julia> write(input, "1 + π;")
7

julia> readavailable(output) |> String |> print

incorrect syntax: ? is not an infix operator
1 + �?

Any ideas would be appreciated!

(version is 0.5.1 if that could matter)

For comparison, I get a similar “incorrect syntax” response from Maxima(GCL) on Linux, either from the Julia pipe sequence you show (after including newlines in the input strings), or when submitting the unicode string to maxima as a batch string from a shell command line. OTOH, the maxima REPL accepts the unicode. You might need to force maxima to recognize that input is utf8 when connected to pipes. (My GCL version doesn’t really handle unicode, so I can’t test that part.)

To check whether the pipes themselves are clean:

julia> inp=Pipe(); outp=Pipe();

julia> p=spawn(`julia`,(inp,outp,STDERR))
Process(`julia`, ProcessRunning)

julia> write(inp,"cos(π)\n")
8

julia> readavailable(outp) |> String |> print
-1.0

Note that Julia (at least here) doesn’t print a banner when connected to pipes.

1 Like

Ahh, thanks for that test. Yes it seems the pipes are clean on windows with your Julia example. This is shaping up to a Maxima issue i think because I’ve has similar problems with ECL (unicode works at the REPL but not over TCP for example). Thanks for the help @Ralph_Smith!