Character codes: Difference between revisions

Content added Content deleted
(Added R code)
(→‎TI-89 BASIC: new example)
Line 346: Line 346:
puts [scan "π" %c] ;# ==> 960
puts [scan "π" %c] ;# ==> 960
puts [format %c 960] ;# ==> π</lang>
puts [format %c 960] ;# ==> π</lang>

=={{header|TI-89 BASIC}}==

The TI-89 uses an 8-bit charset/encoding which is similar to ISO-8859-1, but with more mathematical symbols and Greek letters. At least codes 14-31, 128-160, 180 differ. The ASCII region is unmodified. (TODO: Give a complete list.)

The TI Connect X desktop software converts between this unique character set and Unicode characters, though sometimes in a consistent but inappropriate fashion. <!-- Only Mac experience went into this statement; info for other platforms? -->

The below program will display the character and code for any key pressed. Some keys do not correspond to characters and have codes greater than 255. The portion of the program actually implementing the task is marked with a line of “©”s.

<pre style="font-family:'TI Uni'">Prgm
Local k, s
ClrIO
Loop
Disp "Press a key, or ON to exit."
getKey() © clear buffer
0 → k : While k = 0 : getKey() → k : EndWhile
ClrIO
If k ≥ 256 Then
Disp "Not a character."
Disp "Code: " & string(k)
Else

char(k) → s ©
© char() and ord() are inverses. ©
Disp "Character: " & s ©
Disp "Code: " & string(ord(s)) ©

EndIf
EndLoop
EndPrgm</pre>


=={{header|Visual Basic .NET}}==
=={{header|Visual Basic .NET}}==