Character codes: Difference between revisions

Content added Content deleted
(Added PicoLisp)
Line 330:
<lang powershell>[char] 97 # a
[char] 9786 # ☺</lang>
=={{header|PureBasic}}==
 
PureBasic allows compiling code so that it will use either Ascii or a Unicode (UCS-2) encoding for representing its string content. It also allows for the source code that is being compiled to be in either Ascii or UTF-8 encoding. A one-character string is used here to hold the character and a numerical character type is used to hold the character code. The character type is either one or two bytes in size, depending on whether compiling for Ascii or Unicode respectively.
<lang PureBasic>OpenConsole()
;Results are the same when compiled for Ascii or Unicode
charCode.c = 97
Char.s = "a"
PrintN(Chr(charCode)) ;prints a
PrintN(Str(Asc(Char))) ;prints 97
 
Repeat:Until Inkey() <> ""</lang>
 
This version should be compiled with Unicode setting and the source code to be encoded using UTF-8.
<lang PureBasic>OpenConsole()
;UTF-8 encoding compiled for Unicode (UCS-2)
charCode.c = 960
Char.s = "π"
PrintN(Chr(charCode)) ;prints π
PrintN(Str(Asc(Char))) ;prints 960
 
Repeat:Until Inkey() <> ""</lang>
 
=={{header|Python}}==