Terminal control/Display an extended character: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(24 intermediate revisions by 16 users not shown)
Line 6:
Specifically, display a &nbsp; <big> £ </big> &nbsp; (GBP currency sign).
<br><br>
 
=={{header|11l}}==
<syntaxhighlight lang="11l">print(‘£’)</syntaxhighlight>
 
=={{header|ACL2}}==
<langsyntaxhighlight Lisplang="lisp">(cw "£")</langsyntaxhighlight>
 
=={{header|Action!}}==
<syntaxhighlight lang="action!">PROC Main()
BYTE CHBAS=$02F4 ;Character Base Register
 
CHBAS=$CC ;set the international character set
Position(2,2)
Put(8) ;print the GBP currency sign
RETURN</syntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Display_an_extended_character.png Screenshot from Atari 8-bit computer]
<pre>
£
</pre>
 
=={{header|Ada}}==
 
<langsyntaxhighlight lang="ada">with Ada.Text_IO; use Ada.Text_IO;
with Ada.Characters.Latin_1;
 
Line 18 ⟶ 35:
begin
Put(Ada.Characters.Latin_1.Pound_Sign);
end Pound;</langsyntaxhighlight>
 
Ada allows Unicode characters in the source, and provides output functions on "wide characters".
 
<langsyntaxhighlight lang="ada">with Ada.Wide_Text_IO; use Ada.Wide_Text_IO;
 
procedure Unicode is
begin
Put("札幌");
end Unicode;</langsyntaxhighlight>
 
=={{header|Arturo}}==
 
<syntaxhighlight lang="rebol">print "£"</syntaxhighlight>
 
{{out}}
 
<pre>£</pre>
 
=={{header|AutoHotkey}}==
 
<syntaxhighlight lang="autohotkey">msgbox % chr(163)</syntaxhighlight>
 
=={{header|AWK}}==
Line 33 ⟶ 62:
You can print a literal "£".
 
<langsyntaxhighlight lang="awk">BEGIN { print "£" }</langsyntaxhighlight>
 
You can print a "£" using the escape sequences that match the encoding of your terminal.
Line 54 ⟶ 83:
|}
 
<langsyntaxhighlight lang="awk">BEGIN { print "\302\243" } # if your terminal is utf-8</langsyntaxhighlight>
 
=={{header|BaCon}}==
<syntaxhighlight lang="freebasic">' Display extended character, pound sterling
LET c$ = UTF8$(0xA3)
PRINT c$</syntaxhighlight>
 
=={{header|BASIC}}==
=== {{header|Applesoft BASIC}} ===
Poke the glyph onto the hi-res screen.
<langsyntaxhighlight lang="basic">10 DATA 56,68,4,14,4,4,122,0
20 HGR
30 FOR I = 8192 TO 16383 STEP 1024
40 READ B: POKE I,B: NEXT</langsyntaxhighlight>
 
==={{header|BASIC256}}===
<syntaxhighlight lang="freebasic">print "£"
 
# or
 
print chr(163)</syntaxhighlight>
 
 
==={{header|IS-BASIC}}===
<langsyntaxhighlight ISlang="is-BASICbasic">PRINT "£"</langsyntaxhighlight>
 
or
 
<syntaxhighlight lang IS="is-BASICbasic">PRINT CHR$(35)</langsyntaxhighlight>
 
 
==={{header|QBasic}}===
<syntaxhighlight lang="qbasic">PRINT "£"
 
' or
 
PRINT CHR$(156)
END</syntaxhighlight>
 
 
==={{header|True BASIC}}===
<syntaxhighlight lang="qbasic">PRINT "£"
 
! or
 
PRINT CHR$(163)
END</syntaxhighlight>
 
 
=== {{header|ZX Spectrum Basic}} ===
The ZX Spectrum uses a modified ascii character set that has a uk pound sign at character number 96:
 
<syntaxhighlight lang ="basic">10 PRINT CHR$(96);</langsyntaxhighlight>
 
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
You can print a literal £ if it is available in the default ANSI code page:
<langsyntaxhighlight lang="bbcbasic"> PRINT "£"</langsyntaxhighlight>
But to be on the safe side you can do this:
<langsyntaxhighlight lang="bbcbasic"> VDU 23,22,640;512;8,16,16,128+8 : REM Enable UTF-8 mode
PRINT CHR$(&C2) CHR$(&A3) : REM UTF-8 encoding for £</langsyntaxhighlight>
 
=={{header|bc}}==
You can print a literal "£".
 
<langsyntaxhighlight lang="bc">"£
"
quit</langsyntaxhighlight>
 
=={{header|beeswax}}==
<syntaxhighlight lang ="beeswax">_4~9P.P.M}</langsyntaxhighlight>
 
=={{header|Befunge}}==
Line 98 ⟶ 159:
 
Example output of a pound character in Code page 437:
<langsyntaxhighlight lang="befunge">"| "+,@</langsyntaxhighlight>
 
Example output of a pound character in ISO-8859-1:
<langsyntaxhighlight lang="befunge">"%~"+,@</langsyntaxhighlight>
 
=={{header|Bracmat}}==
<syntaxhighlight lang ="bracmat">put$£</langsyntaxhighlight>
 
=={{header|C}}==
{{trans|AWK}}
<langsyntaxhighlight lang="c">#include <stdio.h>
 
int
Line 116 ⟶ 177:
puts("\302\243"); /* if your terminal is utf-8 */
return 0;
}</langsyntaxhighlight>
 
=={{header|C sharp}}==
<langsyntaxhighlight lang="csharp">class Program
{
static void Main()
Line 125 ⟶ 186:
System.Console.WriteLine("£");
}
}</langsyntaxhighlight>
Output:
<pre>£</pre>
Line 131 ⟶ 192:
=={{header|C++}}==
 
<langsyntaxhighlight lang="cpp">#include <iostream>
 
int main()
Line 137 ⟶ 198:
std::cout << static_cast<char>(163); // pound sign
return 0;
}</langsyntaxhighlight>
 
=={{header|Clojure}}==
<langsyntaxhighlight lang="clojure">(println "£")</langsyntaxhighlight>
 
=={{header|COBOL}}==
{{works with|OpenCOBOL}}
 
<langsyntaxhighlight lang="cobol"> IDENTIFICATION DIVISION.
PROGRAM-ID. Display-Pound.
 
Line 152 ⟶ 213:
 
GOBACK
.</langsyntaxhighlight>
 
=={{header|Common Lisp}}==
<langsyntaxhighlight lang="lisp">
(format t "札幌~%")
(format t "~C~%" (code-char #x00A3))
</syntaxhighlight>
</lang>
 
=={{header|D}}==
Assuming unicode support on the terminal
<langsyntaxhighlight lang="d">import std.stdio;
 
void main() {
writeln('\u00A3');
}</langsyntaxhighlight>
<pre>£</pre>
 
=={{header|Dc}}==
Assuming unicode support on the terminal
<syntaxhighlight lang ="dc">49827 P</langsyntaxhighlight>
 
=={{header|EchoLisp}}==
<langsyntaxhighlight lang="scheme">
;; simplest
(display "£")
Line 183 ⟶ 244:
;; CSS enhancement
(display "£" "color:blue;font-size:2em")
</syntaxhighlight>
</lang>
{{out}}
<span style="color:blue;font-size:2em">
Line 202 ⟶ 263:
The emerging ANS Forth 20xx standard includes an XCHAR wordset which allows manipulation of non-ASCII character sets such as Unicode.
 
<langsyntaxhighlight lang="forth">163 xemit \ , or
s" £" type</langsyntaxhighlight>
 
 
=={{header|FreeBASIC}}==
<syntaxhighlight lang="freebasic">Print Chr(156)</syntaxhighlight>
 
 
=={{header|Go}}==
<langsyntaxhighlight lang="go">package main
 
import "fmt"
Line 212 ⟶ 278:
func main() {
fmt.Println("£")
}</langsyntaxhighlight>
 
=={{header|Haskell}}==
<syntaxhighlight lang="haskell">
<lang Haskell>
module Main where
main = do
putStrLn "£"
putStrLn "札幌"
</syntaxhighlight>
</lang>
 
=={{header|Icon}} and {{header|Unicon}}==
Line 226 ⟶ 292:
Write a given character number, say '163', using <code>char</code> to convert the integer into a string.
 
<syntaxhighlight lang="icon">
<lang Icon>
procedure main ()
write ("£ " || char (163)) # £
end
</syntaxhighlight>
</lang>
 
=={{header|J}}==
<langsyntaxhighlight Jlang="j"> '£'
£
'札幌'
札幌</langsyntaxhighlight>
 
=={{header|Java}}==
<langsyntaxhighlight Javalang="java">import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
 
Line 250 ⟶ 316:
writer.println("札幌");
}
}</langsyntaxhighlight>
 
=={{header|jq}}==
{{works with|jq}}
''Also works with gojq and with jaq''
<syntaxhighlight lang="jq">
"£"
</syntaxhighlight>
or at the command-line:
<syntaxhighlight lang="bash">
jq -rn '"£"'
</syntaxhighlight>
or, using the symbol's codepoint:
<syntaxhighlight lang="bash">
jq -nr '[163]|implode'
</syntaxhighlight>
or:
<syntaxhighlight lang="bash">
jq -nr '"\u00a3"'
</syntaxhighlight>
 
=={{header|Julia}}==
{{trans|C}}
<langsyntaxhighlight lang="julia">println("£")
println("\302\243"); # works if your terminal is utf-8
</syntaxhighlight>
</lang>
 
=={{header|Kotlin}}==
<langsyntaxhighlight lang="scala">// version 1.1.2
 
fun main(args:Array<String>) = println("£")</langsyntaxhighlight>
 
=={{header|Lasso}}==
<syntaxhighlight lang Lasso="lasso">stdout(' £ ')</langsyntaxhighlight>
Result:
<pre> £ </pre>
Line 270 ⟶ 355:
=={{header|Locomotive Basic}}==
 
<syntaxhighlight lang ="locobasic">10 PRINT CHR$(163)</langsyntaxhighlight>
 
=={{header|Lua}}==
Lua requires an extension module for UTF-8 support. However, the '£' symbol specified for this task is part of extended ASCII (codes 128 - 255) which can be accessed in the same way as normal ASCII.
<syntaxhighlight lang Lua="lua">print(string.char(156))</langsyntaxhighlight>
=={{header|M2000 Interpreter}}==
<syntaxhighlight lang="m2000 interpreter">
Print chrcode$(163), "£", chrcode$(127968), "🏠"
</syntaxhighlight>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<syntaxhighlight lang Mathematica="mathematica">FromCharacterCode[{163}]</langsyntaxhighlight>
 
=={{header|NetRexx}}==
<langsyntaxhighlight NetRexxlang="netrexx">/* NetRexx */
options replace format comments java crossref symbols binary
 
Line 295 ⟶ 384:
say (Rexx GBP).d2c
return
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 304 ⟶ 393:
 
=={{header|Nim}}==
<langsyntaxhighlight lang="nim">echo "£"
echo "札幌"
 
import unicode
echo Rune(0xa3)</langsyntaxhighlight>
 
=={{header|Objeck}}==
<langsyntaxhighlight lang="objeck">class Program {
function : Main(args : String[]) ~ Nil {
"£"->PrintLine();
}
}</langsyntaxhighlight>
 
=={{header|Pascal}}==
<langsyntaxhighlight Pascallang="pascal">program pound;
uses crt;
begin
write(chr( 163 ));
end.
</syntaxhighlight>
</lang>
 
=={{header|Perl}}==
<langsyntaxhighlight lang="perl">use feature 'say';
 
# OK as is
Line 335 ⟶ 424:
say "\N{FULLWIDTH POUND SIGN}";
say "\x{FFE1}";
say chr 0xffe1;</langsyntaxhighlight>
 
=={{header|Phix}}==
Line 341 ⟶ 430:
See demo\HelloUTF8.exw for a (not very pretty) way to do that programmaticaly.<br>
The following assumes you have done that manually, and saved the source code file in UTF-8 format.
<!--<syntaxhighlight lang="phix">(phixonline)-->
<lang Phix>puts(1,"£")</lang>
<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;">"£"</span><span style="color: #0000FF;">)</span>
<!--</syntaxhighlight>-->
Output:
<pre>£</pre>
 
=={{header|Picat}}==
<syntaxhighlight lang="picat">go =>
println("£"),
println(chr(163)),
println("太極拳"), % Tàijíquán
nl.</syntaxhighlight>
 
{{out}}
<pre>£
£
太極拳</pre>
 
 
=={{header|PicoLisp}}==
<langsyntaxhighlight PicoLisplang="picolisp">(prinl (char 26413) (char 24140)) # Sapporo </langsyntaxhighlight>
Output:
<pre>札幌</pre>
 
=={{header|PL/I}}==
<langsyntaxhighlight PLlang="pl/Ii"> declare pound character (1) static initial ('9c'x);
put skip list (pound);</langsyntaxhighlight>
 
=={{header|PureBasic}}==
<syntaxhighlight lang PureBasic="purebasic">Print(Chr(163))</langsyntaxhighlight>
<pre>£</pre>
 
=={{header|Python}}==
Python 2:
<lang Python>print u'\u00a3'</lang>
<syntaxhighlight lang="python">print u'\u00a3'</syntaxhighlight>
<pre>£</pre>
Alternatively, as any Unicode character is legal in Python code:
<syntaxhighlight lang="python">£ = '£'
print(£)</syntaxhighlight>
<pre>£</pre>
 
=={{header|R}}==
<syntaxhighlight lang="r">cat("£")</syntaxhighlight>
{{out}}
<pre>£</pre>
 
=={{header|Racket}}==
<langsyntaxhighlight lang="racket">
#lang racket
(display "£")
</syntaxhighlight>
</lang>
 
=={{header|Raku}}==
(formerly Perl 6)
To demonstrate we're not limited to Latin-1, we'll print the fullwidth variant.
<syntaxhighlight lang="raku" perl6line>say '£';
say "\x[FFE1]";
say "\c[FULLWIDTH POUND SIGN]";
0xffe1.chr.say;</langsyntaxhighlight>
 
=={{header|REXX}}==
<langsyntaxhighlight lang="rexx">/*REXX program demonstrates displaying an extended character (glyph) to the terminal. */
/* [↓] this SAY will display the £ glphyglyph (if the term supports it).*/
say '£' /*assumingthis assumes the pound sign glyph is displayable on the termterminal. */
/*this [↑] thisprogram can execute correctly on an EBCDIC or ASCII machine. */
/*stick a fork in it, we're all done. */</langsyntaxhighlight>
{{out|output|text=:}}
<pre>
Line 388 ⟶ 502:
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
# Project : Terminal control/Display an extended character
 
see "£"
</syntaxhighlight>
</lang>
Output:
<pre>
Line 399 ⟶ 513:
 
=={{header|Ruby}}==
<langsyntaxhighlight lang="ruby">#encoding: UTF-8 #superfluous in Ruby > 1.9.3
puts "£"</langsyntaxhighlight>
 
=={{header|Scala}}==
{{libheader|Scala}}<langsyntaxhighlight Scalalang="scala">object ExtendedCharacter extends App {
println("£")
println("札幌")
}</langsyntaxhighlight>
 
=={{header|Seed7}}==
A [http://seed7.sourceforge.net/libraries/console.htm#write%28ref_console_file,in_string%29 write]
to a [http://seed7.sourceforge.net/libraries/console.htm console] accepts Unicode characters.<langsyntaxhighlight lang="seed7">$ include "seed7_05.s7i";
include "console.s7i";
 
Line 423 ⟶ 537:
# the program waits until Return/Enter is pressed.
readln;
end func;</langsyntaxhighlight>
 
=={{header|Sidef}}==
<langsyntaxhighlight lang="ruby">say '£';
say "\x{FFE1}";
say "\N{FULLWIDTH POUND SIGN}";
say 0xffe1.chr;</langsyntaxhighlight>
 
=={{header|Tcl}}==
Provided the system encoding has a “£” symbol in it, this works:
<syntaxhighlight lang ="tcl">puts \u00a3</langsyntaxhighlight>
Tcl can output all unicode characters in the BMP, but only if the consumer of the output (terminal, etc.) is able to understand those characters in its current encoding will the output actually make sense. Strictly, this is not a limitation of Tcl but of the environment in which it is placed.
 
 
=={{header|Verilog}}==
<syntaxhighlight lang="verilog">module main;
initial begin
$display("£");
end
endmodule</syntaxhighlight>
 
 
=={{header|Wren}}==
<syntaxhighlight lang="wren">System.print("£")</syntaxhighlight>
 
=={{header|Xidel}}==
http://videlibri.sourceforge.net/xidel.html
<langsyntaxhighlight lang="bash">xidel -s -e 'parse-html("&#163; or &#xa3")'
£ or £</langsyntaxhighlight>
<langsyntaxhighlight lang="bash">echo '"\u00a3"' | xidel -s - -e 'json($raw)'
£
 
xidel -s -e 'json("""\\u00a3""")' --xquery 'json("&quot;\\u00a3&quot;")'
£
£</langsyntaxhighlight>
 
=={{header|XPL0}}==
<langsyntaxhighlight XPL0lang="xpl0">code ChOut=8;
ChOut(0, $9C) \code for IBM PC's extended (OEM) character set
</syntaxhighlight>
</lang>
 
 
=={{header|Yabasic}}==
<syntaxhighlight lang="freebasic">print chr$(156)</syntaxhighlight>
 
 
=={{header|zkl}}==
If you output device support UTF-8 then:
<langsyntaxhighlight lang="zkl">"\u00a3 \Ua3;".println() //-->£ £</langsyntaxhighlight>
 
 
9,476

edits