Terminal control/Unicode output: Difference between revisions

Content added Content deleted
(Terminal control/Unicode output in FreeBASIC)
m (syntax highlighting fixup automation)
Line 8: Line 8:
=={{header|Arturo}}==
=={{header|Arturo}}==


<lang rebol>canHandleUnicode?: function [][
<syntaxhighlight lang="rebol">canHandleUnicode?: function [][
any? @[
any? @[
if key? env "LC_ALL" -> contains? lower get env "LC_ALL" "utf-8"
if key? env "LC_ALL" -> contains? lower get env "LC_ALL" "utf-8"
Line 19: Line 19:
print "Terminal handle unicode and U+25B3 is: △"
print "Terminal handle unicode and U+25B3 is: △"
else ->
else ->
print "Unicode is not supported on this terminal"</lang>
print "Unicode is not supported on this terminal"</syntaxhighlight>


{{out}}
{{out}}
Line 27: Line 27:
=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==


<lang autohotkey>DllCall("AllocConsole")
<syntaxhighlight lang="autohotkey">DllCall("AllocConsole")
hConsole:=DllCall("GetConsoleWindow","UPtr")
hConsole:=DllCall("GetConsoleWindow","UPtr")
Stdout:=FileOpen(DllCall("GetStdHandle", "int", -11, "ptr"), "h `n")
Stdout:=FileOpen(DllCall("GetStdHandle", "int", -11, "ptr"), "h `n")
Line 81: Line 81:
Pause() {
Pause() {
RunWait, %comspec% /c pause>NUL
RunWait, %comspec% /c pause>NUL
}</lang>
}</syntaxhighlight>


=={{header|AWK}}==
=={{header|AWK}}==


<lang awk>#!/usr/bin/awk -f
<syntaxhighlight lang="awk">#!/usr/bin/awk -f
BEGIN {
BEGIN {
unicodeterm=1 # Assume Unicode support
unicodeterm=1 # Assume Unicode support
Line 109: Line 109:
print "HW65001 This program requires a Unicode compatible terminal"|"cat 1>&2"
print "HW65001 This program requires a Unicode compatible terminal"|"cat 1>&2"
exit 252 # Incompatible hardware
exit 252 # Incompatible hardware
}</lang>
}</syntaxhighlight>


=={{header|BaCon}}==
=={{header|BaCon}}==
<code>LANG</code> environment test borrowed from C solution.
<code>LANG</code> environment test borrowed from C solution.
<lang freebasic>' Determine if the terminal supports Unicode
<syntaxhighlight lang="freebasic">' Determine if the terminal supports Unicode
' if so display delta, if not display error message
' if so display delta, if not display error message
LET lc$ = GETENVIRON$("LANG")
LET lc$ = GETENVIRON$("LANG")
Line 120: Line 120:
ELSE
ELSE
EPRINT "Sorry, terminal is not testing as unicode ready"
EPRINT "Sorry, terminal is not testing as unicode ready"
END IF</lang>
END IF</syntaxhighlight>


=={{header|BBC BASIC}}==
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
{{works with|BBC BASIC for Windows}}
<lang bbcbasic> VDU 23,22,640;512;8,16,16,128+8 : REM Enable UTF-8 mode
<syntaxhighlight lang="bbcbasic"> VDU 23,22,640;512;8,16,16,128+8 : REM Enable UTF-8 mode
*FONT Arial Unicode MS,36
*FONT Arial Unicode MS,36
PRINT CHR$(&E2)+CHR$(&96)+CHR$(&B3)</lang>
PRINT CHR$(&E2)+CHR$(&96)+CHR$(&B3)</syntaxhighlight>


=={{header|C}}==
=={{header|C}}==
<syntaxhighlight lang="c">
<lang c>
#include<stdlib.h>
#include<stdlib.h>
#include<stdio.h>
#include<stdio.h>
Line 156: Line 156:
return 0;
return 0;
}
}
</syntaxhighlight>
</lang>
Output:
Output:
<pre>
<pre>
Line 163: Line 163:


=={{header|Clojure}}==
=={{header|Clojure}}==
<lang clojure>
<syntaxhighlight lang="clojure">
(if-not (empty? (filter #(and (not (nil? %)) (.contains (.toUpperCase %) "UTF"))
(if-not (empty? (filter #(and (not (nil? %)) (.contains (.toUpperCase %) "UTF"))
(map #(System/getenv %) ["LANG" "LC_ALL" "LC_CTYPE"])))
(map #(System/getenv %) ["LANG" "LC_ALL" "LC_CTYPE"])))
"Unicode is supported on this terminal and U+25B3 is : \u25b3"
"Unicode is supported on this terminal and U+25B3 is : \u25b3"
"Unicode is not supported on this terminal.")
"Unicode is not supported on this terminal.")
</syntaxhighlight>
</lang>


{{out}}
{{out}}
Line 175: Line 175:
=={{header|Common Lisp}}==
=={{header|Common Lisp}}==
Each implementation has a different "getenv" function, to work with various implementations was created the "my-getenv" function.
Each implementation has a different "getenv" function, to work with various implementations was created the "my-getenv" function.
<lang lisp>
<syntaxhighlight lang="lisp">
(defun my-getenv (name &optional default)
(defun my-getenv (name &optional default)
#+CMU
#+CMU
Line 195: Line 195:
(format t "Unicode is not supported on this terminal.~&")
(format t "Unicode is not supported on this terminal.~&")
)
)
</syntaxhighlight>
</lang>
{{out}}
{{out}}
<pre>Unicode is supported on this terminal and U+25B3 is : △</pre>
<pre>Unicode is supported on this terminal and U+25B3 is : △</pre>


=={{header|Elixir}}==
=={{header|Elixir}}==
<lang elixir>
<syntaxhighlight lang="elixir">
if ["LANG", "LC_CTYPE", "LC_ALL"]
if ["LANG", "LC_CTYPE", "LC_ALL"]
|> Enum.map(&System.get_env/1)
|> Enum.map(&System.get_env/1)
Line 209: Line 209:
raise "This terminal does not support Unicode."
raise "This terminal does not support Unicode."
end
end
</syntaxhighlight>
</lang>


=={{header|FreeBASIC}}==
=={{header|FreeBASIC}}==
<lang freebasic>Print "Terminal handle unicode and U+25B3 is: "; WChr(&H25B3)</lang>
<syntaxhighlight lang="freebasic">Print "Terminal handle unicode and U+25B3 is: "; WChr(&H25B3)</syntaxhighlight>


=={{header|FunL}}==
=={{header|FunL}}==
<lang funl>if map( v -> System.getenv(v), ["LC_ALL", "LC_CTYPE", "LANG"]).filter( (!= null) ).exists( ('UTF' in) )
<syntaxhighlight lang="funl">if map( v -> System.getenv(v), ["LC_ALL", "LC_CTYPE", "LANG"]).filter( (!= null) ).exists( ('UTF' in) )
println( '\u25b3' )
println( '\u25b3' )
else
else
println( 'Unicode not supported' )</lang>
println( 'Unicode not supported' )</syntaxhighlight>


=={{header|Go}}==
=={{header|Go}}==
{{works with|Ubuntu 16.04}}
{{works with|Ubuntu 16.04}}
<lang go>package main
<syntaxhighlight lang="go">package main


import (
import (
Line 237: Line 237:
fmt.Println("This terminal does not support unicode")
fmt.Println("This terminal does not support unicode")
}
}
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 245: Line 245:


=={{header|Haskell}}==
=={{header|Haskell}}==
<lang Haskell>import System.Environment
<syntaxhighlight lang="haskell">import System.Environment
import Data.List
import Data.List
import Data.Char
import Data.Char
Line 255: Line 255:
then putStrLn "UTF supported: \x25b3"
then putStrLn "UTF supported: \x25b3"
else putStrLn "UTF not supported"
else putStrLn "UTF not supported"
</syntaxhighlight>
</lang>
Output:
Output:
<pre>
<pre>
Line 269: Line 269:


"has_unicode_support" therefore cannot simply test whether one of the variables LC_ALL, LC_TYPE and LANG contains the string UTF.
"has_unicode_support" therefore cannot simply test whether one of the variables LC_ALL, LC_TYPE and LANG contains the string UTF.
<lang jq>def has_unicode_support:
<syntaxhighlight lang="jq">def has_unicode_support:
def utf: if . == null then false else contains("UTF") or contains("utf") end;
def utf: if . == null then false else contains("UTF") or contains("utf") end;
env.LC_ALL
env.LC_ALL
Line 283: Line 283:
end ;
end ;


task</lang>
task</syntaxhighlight>
{{Out}}
{{Out}}
$ jq -M -r -n -f Terminal_control.jq
$ jq -M -r -n -f Terminal_control.jq
Line 294: Line 294:
=={{header|Jsish}}==
=={{header|Jsish}}==
Detection based on code from other entries, looking in LC_ALL, LC_CTYPE, LANG for hints of 'UTF'.
Detection based on code from other entries, looking in LC_ALL, LC_CTYPE, LANG for hints of 'UTF'.
<lang javascript>/* Terminal Control/Unicode, in Jsish */
<syntaxhighlight lang="javascript">/* Terminal Control/Unicode, in Jsish */


var utf = false;
var utf = false;
Line 311: Line 311:
=!EXPECTEND!=
=!EXPECTEND!=
*/</lang>
*/</syntaxhighlight>


{{out}}
{{out}}
Line 319: Line 319:
=={{header|Julia}}==
=={{header|Julia}}==
{{works with|Linux}}
{{works with|Linux}}
<syntaxhighlight lang="julia">
<lang Julia>
c = '\u25b3'
c = '\u25b3'


Line 327: Line 327:
println("This output device does not support Unicode.")
println("This output device does not support Unicode.")
end
end
</syntaxhighlight>
</lang>


{{out}}
{{out}}
Line 336: Line 336:
=={{header|Kotlin}}==
=={{header|Kotlin}}==
{{works with|Ubuntu|14.04}}
{{works with|Ubuntu|14.04}}
<lang scala>// version 1.1.2
<syntaxhighlight lang="scala">// version 1.1.2


fun main(args: Array<String>) {
fun main(args: Array<String>) {
Line 344: Line 344:
else
else
println("This terminal does not support unicode")
println("This terminal does not support unicode")
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 352: Line 352:


=={{header|Lasso}}==
=={{header|Lasso}}==
<lang Lasso>local(env_vars = sys_environ -> join('###'))
<syntaxhighlight lang="lasso">local(env_vars = sys_environ -> join('###'))
if(#env_vars >> regexp(`(LANG|LC_ALL|LC_CTYPE).*?UTF.*?###`)) => {
if(#env_vars >> regexp(`(LANG|LC_ALL|LC_CTYPE).*?UTF.*?###`)) => {
stdout('UTF supported \u25b3')
stdout('UTF supported \u25b3')
else
else
stdout('This terminal does not support UTF')
stdout('This terminal does not support UTF')
}</lang>
}</syntaxhighlight>
<pre>UTF supported △
<pre>UTF supported △
</pre>
</pre>
Line 363: Line 363:
=={{header|M2000 Interpreter}}==
=={{header|M2000 Interpreter}}==
M2000 Environment has own console (with graphics support)
M2000 Environment has own console (with graphics support)
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
Module CheckIt {
Module CheckIt {
If IsWine then Font "DejaVu Sans"
If IsWine then Font "DejaVu Sans"
Line 375: Line 375:
}
}
Checkit
Checkit
</syntaxhighlight>
</lang>


=={{header|Mathematica}}/{{header|Wolfram Language}}==
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<lang Mathematica>If[StringMatchQ[$CharacterEncoding, "UTF*"], Print[FromCharacterCode[30000]], Print["UTF-8 capable terminal required"]]
<syntaxhighlight lang="mathematica">If[StringMatchQ[$CharacterEncoding, "UTF*"], Print[FromCharacterCode[30000]], Print["UTF-8 capable terminal required"]]
->田</lang>
->田</syntaxhighlight>


=={{header|Mercury}}==
=={{header|Mercury}}==
<lang mercury>:- module unicode_output.
<syntaxhighlight lang="mercury">:- module unicode_output.
:- interface.
:- interface.


Line 405: Line 405:
else
else
io.write_string("Unicode is not supported on this terminal.\n", !IO)
io.write_string("Unicode is not supported on this terminal.\n", !IO)
).</lang>
).</syntaxhighlight>
Output:
Output:
<pre>Unicode is supported on this terminal and U+25B3 is : △</pre>
<pre>Unicode is supported on this terminal and U+25B3 is : △</pre>
Line 411: Line 411:
=={{header|Nemerle}}==
=={{header|Nemerle}}==
Typically, on a windows system, the output encoding is '''not''' UTF-8, so in an actual application it would make more sense to set <tt>Console.OutputEncoding</tt> than to merely check it.
Typically, on a windows system, the output encoding is '''not''' UTF-8, so in an actual application it would make more sense to set <tt>Console.OutputEncoding</tt> than to merely check it.
<lang Nemerle>using System.Console;
<syntaxhighlight lang="nemerle">using System.Console;


module UnicodeOut
module UnicodeOut
Line 420: Line 420:
else Write("Console encoding may not support Unicode characters.");
else Write("Console encoding may not support Unicode characters.");
}
}
}</lang>
}</syntaxhighlight>


=={{header|Nim}}==
=={{header|Nim}}==
<lang nim>import os, strutils
<syntaxhighlight lang="nim">import os, strutils


if "utf" in getEnv("LANG").toLower:
if "utf" in getEnv("LANG").toLower:
echo "Unicode is supported on this terminal and U+25B3 is: △"
echo "Unicode is supported on this terminal and U+25B3 is: △"
else:
else:
echo "Unicode is not supported on this terminal."</lang>
echo "Unicode is not supported on this terminal."</syntaxhighlight>


=={{header|Perl}}==
=={{header|Perl}}==
Much like Raku...
Much like Raku...
<lang perl>die "Terminal can't handle UTF-8"
<syntaxhighlight lang="perl">die "Terminal can't handle UTF-8"
unless $ENV{LC_ALL} =~ /utf-8/i or $ENV{LC_CTYPE} =~ /utf-8/i or $ENV{LANG} =~ /utf-8/i;
unless $ENV{LC_ALL} =~ /utf-8/i or $ENV{LC_CTYPE} =~ /utf-8/i or $ENV{LANG} =~ /utf-8/i;


print "△ \n";</lang>
print "△ \n";</syntaxhighlight>


=={{header|Phix}}==
=={{header|Phix}}==
Line 441: Line 441:


The following (grubby low-level details are hidden away in) builtins/unicode_console.e which is now included in the standard distribution:
The following (grubby low-level details are hidden away in) builtins/unicode_console.e which is now included in the standard distribution:
<!--<lang Phix>(phixonline)-->
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">include</span> <span style="color: #000000;">builtins</span><span style="color: #0000FF;">\</span><span style="color: #000000;">cffi</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
<span style="color: #008080;">include</span> <span style="color: #000000;">builtins</span><span style="color: #0000FF;">\</span><span style="color: #000000;">cffi</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
Line 484: Line 484:
<span style="color: #008080;">return</span> <span style="color: #000000;">res</span>
<span style="color: #008080;">return</span> <span style="color: #000000;">res</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<!--</lang>-->
<!--</syntaxhighlight>-->
Which can be used like this:
Which can be used like this:
<!--<lang Phix>(phixonline)-->
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">include</span> <span style="color: #000000;">builtins</span><span style="color: #0000FF;">\</span><span style="color: #000000;">unicode_console</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
<span style="color: #008080;">include</span> <span style="color: #000000;">builtins</span><span style="color: #0000FF;">\</span><span style="color: #000000;">unicode_console</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
Line 498: Line 498:
<span style="color: #7060A8;">puts</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"unicode is not supported\n"</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">puts</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"unicode is not supported\n"</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<!--</lang>-->
<!--</syntaxhighlight>-->
Note that delta does not work on Windows (see talk page) but the others do, and all five work on linux and under pwa/p2js.
Note that delta does not work on Windows (see talk page) but the others do, and all five work on linux and under pwa/p2js.


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==
<lang PicoLisp>(if (sub? "UTF-8" (or (sys "LC_ALL") (sys "LC_CTYPE") (sys "LANG")))
<syntaxhighlight lang="picolisp">(if (sub? "UTF-8" (or (sys "LC_ALL") (sys "LC_CTYPE") (sys "LANG")))
(prinl (char (hex "25b3")))
(prinl (char (hex "25b3")))
(quit "UTF-8 capable terminal required") )</lang>
(quit "UTF-8 capable terminal required") )</syntaxhighlight>


=={{header|Python}}==
=={{header|Python}}==
<lang Python>import sys
<syntaxhighlight lang="python">import sys


if "UTF-8" in sys.stdout.encoding:
if "UTF-8" in sys.stdout.encoding:
print("△")
print("△")
else:
else:
raise Exception("Terminal can't handle UTF-8")</lang>
raise Exception("Terminal can't handle UTF-8")</syntaxhighlight>


=={{header|R}}==
=={{header|R}}==
<lang R>if (any(grepl("UTF", toupper(Sys.getenv(c("LANG", "LC_ALL", "LC_CTYPE")))))) {
<syntaxhighlight lang="r">if (any(grepl("UTF", toupper(Sys.getenv(c("LANG", "LC_ALL", "LC_CTYPE")))))) {
cat("Unicode is supported on this terminal and U+25B3 is : \u25b3\n")
cat("Unicode is supported on this terminal and U+25B3 is : \u25b3\n")
} else {
} else {
cat("Unicode is not supported on this terminal.")
cat("Unicode is not supported on this terminal.")
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 525: Line 525:


=={{header|Racket}}==
=={{header|Racket}}==
<lang racket>
<syntaxhighlight lang="racket">
#lang racket
#lang racket
(displayln
(displayln
Line 531: Line 531:
(or (getenv "LC_ALL") (getenv "LC_CTYPE") (getenv "LANG")))
(or (getenv "LC_ALL") (getenv "LC_CTYPE") (getenv "LANG")))
"\u25b3" "No Unicode detected."))
"\u25b3" "No Unicode detected."))
</syntaxhighlight>
</lang>


=={{header|Raku}}==
=={{header|Raku}}==
(formerly Perl 6)
(formerly Perl 6)
<lang perl6>die "Terminal can't handle UTF-8"
<syntaxhighlight lang="raku" line>die "Terminal can't handle UTF-8"
unless first(*.defined, %*ENV<LC_ALL LC_CTYPE LANG>) ~~ /:i 'utf-8'/;
unless first(*.defined, %*ENV<LC_ALL LC_CTYPE LANG>) ~~ /:i 'utf-8'/;
say "△";</lang>
say "△";</syntaxhighlight>
{{out}}
{{out}}
<pre>△</pre>
<pre>△</pre>


=={{header|Ruby}}==
=={{header|Ruby}}==
<lang ruby>#encoding: UTF-8 # superfluous in Ruby >1.9.3
<syntaxhighlight lang="ruby">#encoding: UTF-8 # superfluous in Ruby >1.9.3


if ENV.values_at("LC_ALL","LC_CTYPE","LANG").compact.first.include?("UTF-8")
if ENV.values_at("LC_ALL","LC_CTYPE","LANG").compact.first.include?("UTF-8")
Line 549: Line 549:
raise "Terminal can't handle UTF-8"
raise "Terminal can't handle UTF-8"
end
end
</syntaxhighlight>
</lang>


=={{header|Scala}}==
=={{header|Scala}}==
Ad hoc in the REPL:
Ad hoc in the REPL:
{{libheader|Scala}}<lang Scala>scala> println(s"Unicode is supported on this terminal and U+25B3 is : \u25b3")
{{libheader|Scala}}<syntaxhighlight lang="scala">scala> println(s"Unicode is supported on this terminal and U+25B3 is : \u25b3")
Unicode is supported on this terminal and U+25B3 is : △</lang>
Unicode is supported on this terminal and U+25B3 is : △</syntaxhighlight>


=={{header|Seed7}}==
=={{header|Seed7}}==
Line 562: Line 562:
output file). STD_CONSOLE supports Unicode under Linux and Windows.
output file). STD_CONSOLE supports Unicode under Linux and Windows.


<lang seed7>$ include "seed7_05.s7i";
<syntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "environment.s7i";
include "environment.s7i";
include "console.s7i";
include "console.s7i";
Line 575: Line 575:
writeln("Unicode is not supported on this terminal.");
writeln("Unicode is not supported on this terminal.");
end if;
end if;
end func;</lang>
end func;</syntaxhighlight>


=={{header|Sidef}}==
=={{header|Sidef}}==
<lang ruby>if (/\bUTF-?8/i ~~ [ENV{"LC_ALL","LC_CTYPE","LANG"}]) {
<syntaxhighlight lang="ruby">if (/\bUTF-?8/i ~~ [ENV{"LC_ALL","LC_CTYPE","LANG"}]) {
say "△"
say "△"
} else {
} else {
die "Terminal can't handle UTF-8.\n";
die "Terminal can't handle UTF-8.\n";
}</lang>
}</syntaxhighlight>


=={{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.<lang tcl># Check if we're using one of the UTF or "unicode" encodings
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.<syntaxhighlight 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]]} {
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>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).
}</syntaxhighlight>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}}==
Line 599: Line 599:


{{works with|Bourne Shell}}
{{works with|Bourne Shell}}
<lang bash>unicode_tty() {
<syntaxhighlight lang="bash">unicode_tty() {
# LC_ALL supersedes LC_CTYPE, which supersedes LANG.
# LC_ALL supersedes LC_CTYPE, which supersedes LANG.
# Set $1 to environment value.
# Set $1 to environment value.
Line 622: Line 622:
echo "HW65001 This program requires a Unicode compatible terminal" >&2
echo "HW65001 This program requires a Unicode compatible terminal" >&2
exit 252 # Incompatible hardware
exit 252 # Incompatible hardware
fi</lang>
fi</syntaxhighlight>


The terminal might support UTF-8, but its fonts might not have every Unicode character. Unless they have U+25B3, the output will not look correct. Greek letters like U+25B3 tend to be common, but some fonts might not have Chinese characters (for example), and almost no fonts have dead scripts such as Cuneiform.
The terminal might support UTF-8, but its fonts might not have every Unicode character. Unless they have U+25B3, the output will not look correct. Greek letters like U+25B3 tend to be common, but some fonts might not have Chinese characters (for example), and almost no fonts have dead scripts such as Cuneiform.
Line 629: Line 629:
{{trans|C}}
{{trans|C}}
As there is currently no way to obtain this information via Wren CLI, we instead embed a Wren script in a C application and ask the host program to get it for us.
As there is currently no way to obtain this information via Wren CLI, we instead embed a Wren script in a C application and ask the host program to get it for us.
<lang ecmascript>/* terminal_control_unicode_output.wren */
<syntaxhighlight lang="ecmascript">/* terminal_control_unicode_output.wren */


class C {
class C {
Line 639: Line 639:
} else {
} else {
System.print("Unicode is not supported on this terminal.")
System.print("Unicode is not supported on this terminal.")
}</lang>
}</syntaxhighlight>
<br>
<br>
We now embed this Wren script in the following C program, compile and run it.
We now embed this Wren script in the following C program, compile and run it.
<lang c>#include <stdlib.h>
<syntaxhighlight lang="c">#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
Line 731: Line 731:
free(script);
free(script);
return 0;
return 0;
}</lang>
}</syntaxhighlight>


{{out}}
{{out}}
Line 740: Line 740:
=={{header|zkl}}==
=={{header|zkl}}==
This code works for Unix/Linux, Windows XP cmd terminals don't support UTF-8.
This code works for Unix/Linux, Windows XP cmd terminals don't support UTF-8.
<lang zkl>if(System.isUnix and T("LC_CTYPE","LC_LANG","LANG").apply(System.getenv)
<syntaxhighlight lang="zkl">if(System.isUnix and T("LC_CTYPE","LC_LANG","LANG").apply(System.getenv)
.filter().filter("holds","UTF"))
.filter().filter("holds","UTF"))
println("This terminal supports UTF-8 (\U25B3;)");
println("This terminal supports UTF-8 (\U25B3;)");
else println("I have doubts about UTF-8 on this terminal.");</lang>
else println("I have doubts about UTF-8 on this terminal.");</syntaxhighlight>
{{out}}
{{out}}
<pre>
<pre>
Line 751: Line 751:
=={{header|ZX Spectrum Basic}}==
=={{header|ZX Spectrum Basic}}==


<lang zxbasic>10 REM There is no Unicode delta in ROM
<syntaxhighlight lang="zxbasic">10 REM There is no Unicode delta in ROM
20 REM So we first define a custom character
20 REM So we first define a custom character
30 FOR l=0 TO 7
30 FOR l=0 TO 7
Line 761: Line 761:
9500 REM data for our custom delta
9500 REM data for our custom delta
9510 DATA 0,0,8,20,34,65,127,0
9510 DATA 0,0,8,20,34,65,127,0
</syntaxhighlight>
</lang>


{{omit from|BASIC}}{{omit from|GUISS}}
{{omit from|Axe}}
{{omit from|Axe}}
{{omit from|BASIC}}
{{omit from|GUISS}}