|
|
|
| 15 March 2003 | AsciiAry() |
| Author | wmarkh@aol.com |
| Action | Returns two-dimensional ASCII array of lower ASCII characters, the type of character (control, symbol, lower, upper, number), the technical name for the character, a mnemonic name for the character, visual substitution character (where applicable), and whether the character is printable or not. |
| Syntax | AsciiAry () |
| Parameters | |
| Remarks | I wrote this while working on a mnemonic password generation script... hence the emphasis on mnemonic names and sight substitution characters. |
| Returns | 128 element X 6 element array |
| Dependencies | None. |
| Examples |
$ascii=AsciiAry()
CLS
DO
At(5,0) 'Enter a symbolic character (i.e. #*!): '
GET $Ch
UNTIL $ascii[Asc($Ch),1]='Symbol'
At(7,0) 'You entered the symbol: ' $Ch
At(8,0) 'The technical name is: ' $ascii[Asc($Ch),2]
; The entire table follows:
;Array Contents:
;DEC CH TYPE NAME MNEMONIC SUB PRT
; 0 o Control... NUL.................... Null.................... 0
; 1 o Control... SOH.................... Start Of Heading........ 0
; 2 o Control... STX.................... Start Of Text........... 0
; 3 o Control... ETX.................... End Of Text............. 0
; 4 o Control... EOT.................... End Of Transmission..... 0
; 5 o Control... ENQ.................... Enquiry................. 0
; 6 o Control... ACK.................... Acknowledge............. 0
; 7 o Control... BEL.................... Bell.................... 0
; 8 o Control... BS..................... Backspace............... 0
; 9 o Control... HT..................... Horizontal Tab.......... 0
; 10 o Control... LF..................... Line Feed............... 0
; 11 o Control... VT..................... Vertical Tab............ 0
; 12 o Control... FF..................... Form Feed............... 0
; 13 o Control... CR..................... Carriage Return......... 0
; 14 o Control... SO..................... Shift Out............... 0
; 15 o Control... SI..................... Shift In................ 0
; 16 o Control... DLE.................... Data Link Escape........ 0
; 17 o Control... DC1.................... Device Control One...... 0
; 18 o Control... DC2.................... Device Control Two...... 0
; 19 o Control... DC3.................... Device Control Three.... 0
; 20 o Control... DC4.................... Device Control Four..... 0
; 21 o Control... NAK.................... Negative Acknowledge.... 0
; 22 o Control... SYN.................... Synchronous Idle........ 0
; 23 o Control... ETB.................... End Transmission Block.. 0
; 24 o Control... CAN.................... Cancel.................. 0
; 25 o Control... EM..................... End Of Medium........... 0
; 26 o Control... SUB.................... Substitute.............. 0
; 27 o Control... ESC.................... Escape.................. 0
; 28 o Control... FS..................... File Separator.......... 0
; 29 o Control... GS..................... Group Separator......... 0
; 30 o Control... RS..................... Record Separator........ 0
; 31 o Control... US..................... Unit Separator.......... 0
; 32 o Symbol.... Space.................. Blank................... 0
; 33 ! Symbol.... Exclamation............ Bang.................... i 1
; 34 " Symbol.... Quote.................. Rabbit Ears............. 1
; 35 # Symbol.... Octothorpe............. Pound................... H 1
; 36 $ Symbol.... Sonne.................. Dollar.................. S 1
; 37 % Symbol.... Percent................ Grapes.................. 1
; 38 & Symbol.... Ampersand.............. And..................... 1
; 39 ' Symbol.... Apostrophe............. Tick.................... 1
; 40 ( Symbol.... Left Parenthesis....... Open.................... C 1
; 41 ) Symbol.... Right Parenthesis...... Close................... 1
; 42 * Symbol.... Asterisk............... Star.................... 1
; 43 + Symbol.... Plus................... Plus.................... t 1
; 44 , Symbol.... Comma.................. ........................ 1
; 45 - Symbol.... Hyphen................. Dash.................... 1
; 46 . Symbol.... Period................. Dot..................... 1
; 47 / Symbol.... Slash.................. ........................ 1
; 48 0 Number.... Zero................... ........................ O 1
; 49 1 Number.... One.................... ........................ l 1
; 50 2 Number.... Two.................... ........................ 1
; 51 3 Number.... Three.................. ........................ 1
; 52 4 Number.... Four................... ........................ 1
; 53 5 Number.... Five................... ........................ 1
; 54 6 Number.... Six.................... ........................ 1
; 55 7 Number.... Seven.................. ........................ 1
; 56 8 Number.... Eight.................. ........................ 1
; 57 9 Number.... Nine................... ........................ g 1
; 58 : Symbol.... Colon.................. Double Dot.............. 1
; 59 ; Symbol.... Semicolon.............. Semi.................... j 1
; 60 < Symbol.... Left Angle Bracket..... Less Than............... 1
; 61 = Symbol.... Quadrathorpe........... Equals.................. 1
; 62 > Symbol.... Right Angle Bracket.... Greater Than............ 1
; 63 ? Symbol.... Interrogation.......... Question................ 1
; 64 @ Symbol.... At..................... At...................... e 1
; 65 A Upper..... Aye.................... ........................ ^ 1
; 66 B Upper..... Bee.................... ........................ 1
; 67 C Upper..... Cee.................... ........................ ( 1
; 68 D Upper..... Dee.................... ........................ 1
; 69 E Upper..... Ee..................... ........................ [ 1
; 70 F Upper..... Eff.................... ........................ 1
; 71 G Upper..... Gee.................... ........................ 1
; 72 H Upper..... Aitch.................. ........................ # 1
; 73 I Upper..... Aye.................... ........................ | 1
; 74 J Upper..... Jay.................... ........................ 1
; 75 K Upper..... Kay.................... ........................ 1
; 76 L Upper..... Ell.................... ........................ 1
; 77 M Upper..... Em..................... ........................ 1
; 78 N Upper..... En..................... ........................ 1
; 79 O Upper..... Oh..................... ........................ 0 1
; 80 P Upper..... Pee.................... ........................ 1
; 81 Q Upper..... Que.................... ........................ 1
; 82 R Upper..... Ar..................... ........................ 1
; 83 S Upper..... Ess.................... ........................ $ 1
; 84 T Upper..... Tee.................... ........................ 1
; 85 U Upper..... Ewe.................... ........................ 1
; 86 V Upper..... Vee.................... ........................ 1
; 87 W Upper..... Double-Ewe............. ........................ 1
; 88 X Upper..... Ecks................... ........................ 1
; 89 Y Upper..... Wye.................... ........................ 1
; 90 Z Upper..... Zee.................... ........................ 1
; 91 [ Symbol.... Left Bracket........... Bracket................. E 1
; 92 \ Symbol.... Reverse Virgule........ Backslash............... 1
; 93 ] Symbol.... Right Bracket.......... Unbracket............... 1
; 94 ^ Symbol.... Caret.................. Hat..................... A 1
; 95 _ Symbol.... Underscore............. Under................... 1
; 96 ` Symbol.... Grave.................. Backtick................ 1
; 97 a Lower..... Aye.................... ........................ 1
; 98 b Lower..... Bee.................... ........................ 1
; 99 c Lower..... Cee.................... ........................ 1
;100 d Lower..... Dee.................... ........................ 1
;101 e Lower..... Ee..................... ........................ @ 1
;102 f Lower..... Eff.................... ........................ 1
;103 g Lower..... Gee.................... ........................ 9 1
;104 h Lower..... Aitch.................. ........................ 1
;105 i Lower..... Aye.................... ........................ ! 1
;106 j Lower..... Jay.................... ........................ ; 1
;107 k Lower..... Kay.................... ........................ 1
;108 l Lower..... Ell.................... ........................ 1 1
;109 m Lower..... Em..................... ........................ 1
;110 n Lower..... En..................... ........................ 1
;111 o Lower..... Oh..................... ........................ 1
;112 p Lower..... Pee.................... ........................ 1
;113 q Lower..... Que.................... ........................ 1
;114 r Lower..... Ar..................... ........................ 1
;115 s Lower..... Ess.................... ........................ 1
;116 t Lower..... Tee.................... ........................ + 1
;117 u Lower..... Ewe.................... ........................ 1
;118 v Lower..... Vee.................... ........................ 1
;119 w Lower..... Double-Ewe............. ........................ 1
;120 x Lower..... Ecks................... ........................ 1
;121 y Lower..... Wye.................... ........................ 1
;122 z Lower..... Zee.................... ........................ 1
;123 { Symbol.... Left Brace............. Embrace................. 1
;124 | Symbol.... Bar.................... Whack................... I 1
;125 } Symbol.... Right Brace............ Unbrace................. 1
;126 ~ Symbol.... Tilde.................. Twiddle................. 1
;127 o Symbol.... Delete................. ........................ 0
|
| Source |
FUNCTION AsciiAry ()
;Returns a two-dimensional array of the lower ASCII set (0-127)
;as follows:
; 127 Rows
; 6 Columns as follows:
;
; 0=Character
; 1=Type (symbol, number, etc.)
; 2=Name (typesetting/technical name)
; 3=Mnemonic (some characters have many nicknames -- I'm just picking
; unusual ones for memorization, not necessarily the most popular
; names by any means)
; 4=Sight substitution character (Cross-referenced, i.e. H=# and #=H)
; 5=(boolean) printable character. True=Yes=1, else 0. Space is listed
; as a non-printable character. Obviously, this will vary by
; application.
;
DIM $i, $j, $ch1, $ch2, $ch3
;Initialize array
REDIM $asciiary[127,5]
FOR $i = 0 TO 127
$asciiary[$i,0]=Chr($i)
$asciiary[$i,1]=''
$asciiary[$i,2]=Chr($i)
$asciiary[$i,3]=''
$asciiary[$i,4]=''
$asciiary[$i,5]=1
NEXT
;Initialize obvious characters and names, along with type.
FOR $i = 0 TO 127
SELECT
CASE $i < 32
$asciiary[$i,0]='Ctrl-'+Chr($i+64)
$asciiary[$i,1]='Control'
$asciiary[$i,5]=0
CASE $i > 47 AND $i < 58
$asciiary[$i,1]='Number'
CASE $i > 64 AND $i < 91
$asciiary[$i,1]='Upper'
CASE $i > 96 AND $i < 123
$asciiary[$i,1]='Lower'
CASE $i > 127
$asciiary[$i,1]='Extended'
CASE 1
$asciiary[$i,1]='Symbol'
ENDSELECT
NEXT
;Add abbreviated names for control characters
REDIM $atmp[31]
$atmp1='NUL','SOH','STX','ETX','EOT','ENQ','ACK','BEL','BS','HT','LF','VT',
'FF','CR','SO','SI','DLE','DC1','DC2','DC3','DC4','NAK','SYN','ETB',
'CAN','EM','SUB','ESC','FS','GS','RS','US'
FOR $i = 0 TO 31
$asciiary[$i,2]=$atmp1[$i]
NEXT
;Add full names for control characters
$atmp1='Null','Start Of Heading','Start Of Text','End Of Text','End Of Transmission',
'Enquiry','Acknowledge','Bell','Backspace','Horizontal Tab','Line Feed','Vertical Tab',
'Form Feed','Carriage Return','Shift Out','Shift In','Data Link Escape',
'Device Control One','Device Control Two','Device Control Three','Device Control Four',
'Negative Acknowledge','Synchronous Idle','End Transmission Block','Cancel',
'End Of Medium','Substitute','Escape','File Separator','Group Separator',
'Record Separator','Unit Separator'
FOR $i = 0 TO 31
$asciiary[$i,3]=$atmp1[$i]
NEXT
;Add character names and mnemonics for symbols (next several sections)
REDIM $atmp1[15]
$atmp1='Space','Exclamation','Quote','Octothorpe','Sonne','Percent','Ampersand',
'Apostrophe','Left Parenthesis','Right Parenthesis','Asterisk','Plus','Comma',
'Hyphen','Period','Slash'
REDIM $atmp2[15]
$atmp2='Blank','Bang','Rabbit Ears','Pound','Dollar','Grapes','And',
'Tick','Open','Close','Star','Plus','','Dash','Dot',''
FOR $i = 0 TO 15
$asciiary[$i+32,2]=$atmp1[$i]
$asciiary[$i+32,3]=$atmp2[$i]
NEXT
$asciiary[32,5]=0 ;Make the space character non-printable
REDIM $atmp1[6]
$atmp1='Colon','Semicolon','Left Angle Bracket','Quadrathorpe',
'Right Angle Bracket','Interrogation','At'
REDIM $atmp2[6]
$atmp2='Double Dot','Semi','Less Than','Equals',
'Greater Than','Question','At'
FOR $i = 0 TO 6
$asciiary[$i+58,2]=$atmp1[$i]
$asciiary[$i+58,3]=$atmp2[$i]
NEXT
REDIM $atmp1[5]
$atmp1='Left Bracket','Reverse Virgule','Right Bracket','Caret','Underscore','Grave'
REDIM $atmp2[5]
$atmp2='Bracket','Backslash','Unbracket','Hat','Under','Backtick'
FOR $i = 0 TO 5
$asciiary[$i+91,2]=$atmp1[$i]
$asciiary[$i+91,3]=$atmp2[$i]
NEXT
REDIM $atmp1[4]
$atmp1='Left Brace','Bar','Right Brace','Tilde','Delete'
REDIM $atmp2[4]
$atmp2='Embrace','Whack','Unbrace','Twiddle',''
FOR $i = 0 TO 4
$asciiary[$i+123,2]=$atmp1[$i]
$asciiary[$i+123,3]=$atmp2[$i]
NEXT
$asciiary[127,5]=0 ;Delete character not normally printable
;Add phonetic names for letters
REDIM $atmp1[25]
$atmp1='Aye','Bee','Cee','Dee','Ee','Eff','Gee','Aitch','Aye','Jay','Kay',
'Ell','Em','En','Oh','Pee','Que','Ar','Ess','Tee','Ewe','Vee',
'Double-Ewe','Ecks','Wye','Zee'
FOR $i = 0 TO 25
$asciiary[$i+65,2]=$atmp1[$i]
$asciiary[$i+97,2]=$atmp1[$i]
NEXT
;Add names for digits
REDIM $atmp1[9]
$atmp1='Zero','One','Two','Three','Four','Five','Six','Seven','Eight','Nine'
FOR $i = 0 TO 9
$asciiary[$i+48,2]=$atmp1[$i]
NEXT
;Add visual substitution characters
REDIM $atmp1[12]
REDIM $atmp2[12]
$atmp1='t','S','H','I','O','j','l','C','E','A','g','i','e'
$atmp2='+','$$','#','|','0',';','1','(','[','^','9','!','@@'
FOR $i = 0 TO UBound($atmp1)
$ch1=$atmp1[$i]
$ch2=$atmp2[$i]
FOR $j = 32 TO 126
$ch3=$asciiary[$j,0]
IF $ch1 == $ch3
$asciiary[$j,4]=$ch2
ENDIF
IF $ch2 == $ch3
$asciiary[$j,4]=$ch1
ENDIF
NEXT
NEXT
ENDFUNCTION ; - AsciiAry -
|
|
|
|