Jump to content

ASCII control characters: Difference between revisions

Initial submission for ASCII control characters
m (→‎{{header|Wren}}: Changed to Wren S/H)
(Initial submission for ASCII control characters)
Line 150:
<pre> D
7F</pre>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
local fn ASCIIControlInfo( asciiControl as CFStringRef ) as CFStringRef
asciiControl = lcase(asciiControl)
if fn StringIsEqual( asciiControl, @"space" ) then asciiControl = @"spc"
if fn StringIsEqual( asciiControl, @"delete" ) then asciiControl = @"del"
CFStringRef result
CFDictionaryRef asciiDict = @{
@"etx": @"3 03 003 End of text",
@"eot": @"4 04 004 End of transmission",
@"enq": @"5 05 005 Enquiry",
@"ack": @"6 06 006 Acknowledge",
@"bel": @"7 07 007 Bell",
@"bs" : @"8 08 010 Backspace",
@"ht" : @"9 09 011 Horizontal tab",
@"lf" : @"10 0A 012 Line feed",
@"vt" : @"11 0B 013 Vertical tab",
@"ff" : @"12 0C 014 New page/form feed",
@"cr" : @"13 0D 015 Carriage return",
@"so" : @"14 0E 016 Shift out",
@"si" : @"15 0F 017 Shift in",
@"dle": @"16 10 020 Data link escape",
@"dc1": @"17 11 021 Device control 1",
@"dc2": @"18 12 022 Device control 2",
@"dc3": @"19 13 023 Device control 3",
@"dc4": @"20 14 024 Device control 4",
@"nak": @"21 15 025 Negative acknowledge",
@"syn": @"22 16 026 Synchronous idle",
@"etb": @"23 17 027 End of transmission block",
@"can": @"24 18 030 Cancel",
@"em" : @"25 19 031 End of medium",
@"sub": @"26 1A 032 Substitute",
@"esc": @"27 1B 033 Escape",
@"fs" : @"28 1C 034 File separator",
@"gs" : @"29 1D 035 Group separator",
@"rs" : @"30 1E 036 Record separator",
@"us" : @"31 1F 037 Unit separator",
@"spc": @"32 20 040 Space",
@"del": @"127 7F 177 Delete"}
 
if ( asciiDict[asciiControl] )
result = fn StringWithFormat( @"Ctl\t\tDec\t\tHex\t\tOct\t\tDescription\n%@\t\t%@\n", asciiControl, asciiDict[asciiControl] )
else
result = fn StringWithFormat( @"Error: %@ is not an ASCII control\n", asciiControl )
end if
end fn = result
 
print fn ASCIIControlInfo( @"vt" )
print fn ASCIIControlInfo( @"CR" )
print fn ASCIIControlInfo( @"Si" )
print fn ASCIIControlInfo( @"ESC" )
print fn ASCIIControlInfo( @"xx" )
print fn ASCIIControlInfo( @"Space" )
print fn ASCIIControlInfo( @"DELETE" )
 
HandleEvents
</syntaxhighlight>
<pre>
Ctl Dec Hex Oct Description
vt 11 0B 013 Vertical tab
 
Ctl Dec Hex Oct Description
cr 13 0D 015 Carriage return
 
Ctl Dec Hex Oct Description
si 15 0F 017 Shift in
 
Ctl Dec Hex Oct Description
esc 27 1B 033 Escape
 
Error: xx is not an ASCII control
 
Ctl Dec Hex Oct Description
spc 32 20 040 Space
 
Ctl Dec Hex Oct Description
del 127 7F 177 Delete
</pre>
 
=={{header|Go}}==
729

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.