Terminal control/Unicode output: Difference between revisions

Content added Content deleted
(→‎Tcl: Added implementation)
m (→‎{{header|Tcl}}: note on what's happening)
Line 34: Line 34:
=={{header|Tcl}}==
=={{header|Tcl}}==
Tcl configures the standard output channel to use the system encoding by default. The system encoding is formally the encoding for use when communicating with the OS (e.g., for filenames) but is virtually always correlated with the default terminal encoding.
Tcl configures the standard output channel to use the system encoding by default. The system encoding is formally the encoding for use when communicating with the OS (e.g., for filenames) but is virtually always correlated with the default terminal encoding.
<lang tcl>if {[string match utf-* [encoding system]] || [string match *unicode* [encoding system]]} {
<lang tcl># Check if we're using one of the UTF or "unicode" encodings
if {[string match utf-* [encoding system]] || [string match *unicode* [encoding system]]} {
puts "\u25b3"
puts "\u25b3"
} else {
} else {
error "terminal does not support unicode (probably)"
error "terminal does not support unicode (probably)"
}</lang>
}</lang>
Note that idiomatic Tcl code would not perform such a check; it would just produce the output which would be translated as best as possible (possibly into the target encoding's placeholder character).


=={{header|UNIX Shell}}==
=={{header|UNIX Shell}}==