Opened 7 years ago

Last modified 7 years ago

#912 new defect

Let's use POSIX locale for *terminal-io* character encoding by default.

Reported by: pjb@… Owned by:
Priority: normal Milestone:
Component: other Version: trunk
Keywords: terminal encoding Cc:


On unix systems, the terminal encoding is specified with the locale environment variables.

Typically, LC_ALL, or LC_MESSAGE, or LC_CTYPE are set to something like en_US.UTF-8 to specify that the terminal uses UTF-8 (and that the user wants messages in US English).

When the -K option is not given, ccl should honor those environment variables, and set the character encoding of the *terminal-io* stream accordingly. If not done by ccl, it means that any program compiled with ccl must be wrapped into a shell script to pass the right -K option...

Alternatively, or additionnally, providing an API to let the program set the character encoding of the *terminal-io* stream would allow the applications to do it themselves. (There's already an API to set the character encoding of the file contents and the socket streams, why not the other sources/sinks of text?).

Change History (1)

comment:1 Changed 7 years ago by pjb@…

I found:

(mapc (lambda (stream)
          (setf (ccl::stream-external-format stream)
                (ccl:make-external-format :domain nil
                                          :character-encoding encoding
                                          :line-termination line-termination)))
        (list (two-way-stream-input-stream  *terminal-io*)
              (two-way-stream-output-stream *terminal-io*)))

which allows my application to set the terminal encoding according to the LC_ environment variables.

So a quick fix would be to publish (export and document) ccl::stream-external-format.

Note: See TracTickets for help on using tickets.