Terminal control/Display an extended character: Difference between revisions
Terminal control/Display an extended character (view source)
Revision as of 11:58, 13 February 2024
, 3 months ago→{{header|Wren}}: Changed to Wren S/H
(Terminal control/Display an extended character en Verilog) |
m (→{{header|Wren}}: Changed to Wren S/H) |
||
(13 intermediate revisions by 11 users not shown) | |||
Line 8:
=={{header|11l}}==
<syntaxhighlight lang
=={{header|ACL2}}==
<
=={{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>
£
=={{header|Ada}}==
<
with Ada.Characters.Latin_1;
Line 21 ⟶ 35:
begin
Put(Ada.Characters.Latin_1.Pound_Sign);
end Pound;</
Ada allows Unicode characters in the source, and provides output functions on "wide characters".
<
procedure Unicode is
begin
Put("札幌");
end Unicode;</
=={{header|Arturo}}==
<
{{out}}
<pre>£</pre>
=={{header|AutoHotkey}}==
<syntaxhighlight lang="autohotkey">msgbox % chr(163)</syntaxhighlight>
=={{header|AWK}}==
Line 44 ⟶ 62:
You can print a literal "£".
<
You can print a "£" using the escape sequences that match the encoding of your terminal.
Line 65 ⟶ 83:
|}
<
=={{header|BaCon}}==
<
LET c$ = UTF8$(0xA3)
PRINT c$</
=={{header|BASIC}}==
==={{header|Applesoft BASIC}}===
Poke the glyph onto the hi-res screen.
<
20 HGR
30 FOR I = 8192 TO 16383 STEP 1024
40 READ B: POKE I,B: NEXT</
==={{header|BASIC256}}===
<syntaxhighlight lang="freebasic">print "£"
# or
print chr(163)</syntaxhighlight>
==={{header|IS-BASIC}}===
<
or
<syntaxhighlight lang
==={{header|QBasic}}===
<
' or
PRINT CHR$(156)
END</
==={{header|True BASIC}}===
<
! or
PRINT CHR$(163)
END</
Line 109 ⟶ 135:
The ZX Spectrum uses a modified ascii character set that has a uk pound sign at character number 96:
<syntaxhighlight lang
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
You can print a literal £ if it is available in the default ANSI code page:
<
But to be on the safe side you can do this:
<
PRINT CHR$(&C2) CHR$(&A3) : REM UTF-8 encoding for £</
=={{header|bc}}==
You can print a literal "£".
<
"
quit</
=={{header|beeswax}}==
<syntaxhighlight lang
=={{header|Befunge}}==
Line 133 ⟶ 159:
Example output of a pound character in Code page 437:
<
Example output of a pound character in ISO-8859-1:
<
=={{header|Bracmat}}==
<syntaxhighlight lang
=={{header|C}}==
{{trans|AWK}}
<
int
Line 151 ⟶ 177:
puts("\302\243"); /* if your terminal is utf-8 */
return 0;
}</
=={{header|C sharp}}==
<
{
static void Main()
Line 160 ⟶ 186:
System.Console.WriteLine("£");
}
}</
Output:
<pre>£</pre>
Line 166 ⟶ 192:
=={{header|C++}}==
<
int main()
Line 172 ⟶ 198:
std::cout << static_cast<char>(163); // pound sign
return 0;
}</
=={{header|Clojure}}==
<
=={{header|COBOL}}==
{{works with|OpenCOBOL}}
<
PROGRAM-ID. Display-Pound.
Line 187 ⟶ 213:
GOBACK
.</
=={{header|Common Lisp}}==
<
(format t "札幌~%")
(format t "~C~%" (code-char #x00A3))
</syntaxhighlight>
▲</lang>
=={{header|D}}==
Assuming unicode support on the terminal
<
void main() {
writeln('\u00A3');
}</
<pre>£</pre>
=={{header|Dc}}==
Assuming unicode support on the terminal
<syntaxhighlight lang
=={{header|EchoLisp}}==
<
;; simplest
(display "£")
Line 218 ⟶ 244:
;; CSS enhancement
(display "£" "color:blue;font-size:2em")
</syntaxhighlight>
{{out}}
<span style="color:blue;font-size:2em">
Line 237 ⟶ 263:
The emerging ANS Forth 20xx standard includes an XCHAR wordset which allows manipulation of non-ASCII character sets such as Unicode.
<
s" £" type</
=={{header|FreeBASIC}}==
<syntaxhighlight lang
=={{header|Go}}==
<
import "fmt"
Line 252 ⟶ 278:
func main() {
fmt.Println("£")
}</
=={{header|Haskell}}==
<syntaxhighlight lang="haskell">
module Main where
main = do
putStrLn "£"
putStrLn "札幌"
</syntaxhighlight>
=={{header|Icon}} and {{header|Unicon}}==
Line 266 ⟶ 292:
Write a given character number, say '163', using <code>char</code> to convert the integer into a string.
<syntaxhighlight lang="icon">
procedure main ()
write ("£ " || char (163)) # £
end
</syntaxhighlight>
=={{header|J}}==
<
£
'札幌'
札幌</
=={{header|Java}}==
<
import java.io.UnsupportedEncodingException;
Line 290 ⟶ 316:
writer.println("札幌");
}
}</
=={{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}}
<
println("\302\243"); # works if your terminal is utf-8
</syntaxhighlight>
=={{header|Kotlin}}==
<
fun main(args:Array<String>) = println("£")</
=={{header|Lasso}}==
<syntaxhighlight lang
Result:
<pre> £ </pre>
Line 310 ⟶ 355:
=={{header|Locomotive Basic}}==
<syntaxhighlight lang
=={{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
=={{header|M2000 Interpreter}}==
<syntaxhighlight lang="m2000 interpreter">
Print chrcode$(163), "£", chrcode$(127968), "🏠"
</syntaxhighlight>
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<syntaxhighlight lang
=={{header|NetRexx}}==
<
options replace format comments java crossref symbols binary
Line 335 ⟶ 384:
say (Rexx GBP).d2c
return
</syntaxhighlight>
{{out}}
<pre>
Line 344 ⟶ 393:
=={{header|Nim}}==
<
echo "札幌"
import unicode
echo Rune(0xa3)</
=={{header|Objeck}}==
<
function : Main(args : String[]) ~ Nil {
"£"->PrintLine();
}
}</
=={{header|Pascal}}==
<
uses crt;
begin
write(chr( 163 ));
end.
</syntaxhighlight>
=={{header|Perl}}==
<
# OK as is
Line 375 ⟶ 424:
say "\N{FULLWIDTH POUND SIGN}";
say "\x{FFE1}";
say chr 0xffe1;</
=={{header|Phix}}==
Line 381 ⟶ 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)-->
<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}}==
<
Output:
<pre>札幌</pre>
=={{header|PL/I}}==
<
put skip list (pound);</
=={{header|PureBasic}}==
<syntaxhighlight lang
<pre>£</pre>
=={{header|Python}}==
Python 2:
<syntaxhighlight lang
<pre>£</pre>
Alternatively, as any Unicode character is legal in Python code:
<
print(£)</
<pre>£</pre>
=={{header|R}}==
<syntaxhighlight lang="r">cat("£")</syntaxhighlight>
{{out}}
<pre>£</pre>
=={{header|Racket}}==
<
#lang racket
(display "£")
</syntaxhighlight>
=={{header|Raku}}==
(formerly Perl 6)
To demonstrate we're not limited to Latin-1, we'll print the fullwidth variant.
<syntaxhighlight lang="raku"
say "\x[FFE1]";
say "\c[FULLWIDTH POUND SIGN]";
0xffe1.chr.say;</
=={{header|REXX}}==
<
say '£'
/*stick a fork in it, we're all done. */</
{{out|output|text=:}}
<pre>
Line 433 ⟶ 502:
=={{header|Ring}}==
<
# Project : Terminal control/Display an extended character
see "£"
</syntaxhighlight>
Output:
<pre>
Line 444 ⟶ 513:
=={{header|Ruby}}==
<
puts "£"</
=={{header|Scala}}==
{{libheader|Scala}}<
println("£")
println("札幌")
}</
=={{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.<
include "console.s7i";
Line 468 ⟶ 537:
# the program waits until Return/Enter is pressed.
readln;
end func;</
=={{header|Sidef}}==
<
say "\x{FFE1}";
say "\N{FULLWIDTH POUND SIGN}";
say 0xffe1.chr;</
=={{header|Tcl}}==
Provided the system encoding has a “£” symbol in it, this works:
<syntaxhighlight lang
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}}==
<
initial begin
$display("£");
end
endmodule</
=={{header|Wren}}==
<
=={{header|Xidel}}==
http://videlibri.sourceforge.net/xidel.html
<
£ or £</
<
£
xidel -s -e 'json("""\\u00a3""")' --xquery 'json(""\\u00a3"")'
£
£</
=={{header|XPL0}}==
<
ChOut(0, $9C) \code for IBM PC's extended (OEM) character set
</syntaxhighlight>
=={{header|Yabasic}}==
<syntaxhighlight lang
=={{header|zkl}}==
If you output device support UTF-8 then:
<
|