The DP_AlphaWords library provides a simple method for converting arbitrary text to a list of words which help to disambiguate spelling. For example the word “CAT” may be translated to “Charlie Alfa Tango”.

This translation is useful when communicating information where spelling is crucial (computer passwords, names, license plate numbers, etc) over the phone or radio. It may also be useful when presenting potentially ambigious information such as randomly generated user names or passwords.

The function can output a simple list or can output a verbose script suitable for reading. The verbose output support several formatting options.

The function supports most typable english characters and will translate them to their names. For example the character “}” will be translated to “Right Curly Brace”.

The function supports several alphabet standards.

NATO: The NATO phonetic alphabet (used by most international and military agencies). Source.

LAPD: The Los Angeles Police Department alphabet (used by most law enforcement and emergency service agencies in the US). Source.

AlphaSet: String, Optional (defaults to NATO). The alphabet set to use in the conversion. Acceptable values are “NATO”, “LAPD”, “Army1916”, “Army1939”, “Army1944”, “RAF1924”, “RAF1942”, “RAF1943”, “Gorey” or “Grover”.

Simple: Each character is translated directly to the corrosponding word.

Verbose: Each character is presented again and translated to a phrase including character type and case information in addition to the corrosponding word.

Array: The string is converted to an array where each element is an object with information about the character. These objects have the following properties:

Char: The character itself.

Code: The ASCII code of the character.

Trans: The “translation” of the character (depends upon the Alphabet set used).

Type: The type of character. Value will be one of the following: “Lowercase”, “Uppercase”, “Number”, “Unknown” or “Symbol”.

OutputPrefix: String, Optional (defaults to an empty string). This string will be prefixed (inserted before) to the translation of each character. This argument is ignored if the OutputStyle is “Array”.

OutputPostfix: String, Optional (defaults to a space). This string will be postfixed (inserted after) to the translation of each character. This argument is ignored if the OutputStyle is “Array”.

OutputIncludeCSS: Boolean, Optional (defaults to false). If true the output will be tagged with CSS identifiers (using span tags) which the developer can set. These declarations are “dpAlphaWords_Char” (applied to the character in Verbose-style output) and “dpAlphaWords_Trans” (applied to the translation). Note that for long inputs including CSS can dramtically increase the size of the output.

Return

String. The function returns the translation of the input string according to the arguments passed.

Verbose Conversions

Verbose conversions are more appropriate for generating readable scripts where case matters. You’ll mostly likely want to format verbose output in some way. For example here is verbose output formatted with line breaks between each translation:

dpAlphaWords("Alphabet", "LAPD", "Verbose", "", "&lt;br&gt;");

This would return:

Uppercase “A” as in Adam
Lowercase “l” as in Lincoln
Lowercase “p” as in Paul
Lowercase “h” as in Henry
Lowercase “a” as in Adam
Lowercase “b” as in Boy
Lowercase “e” as in Edward
Lowercase “t” as in Tom

Verbose conversions are easier to understand than simple conversions when symbols and numerals are involved. Consider the following conversion of a randomly generated password:

dpAlphaWords("K$rT12(]f", "NATO", "Verbose", "", "&lt;br&gt;");

This would return:

Uppercase “K” as in Kilo
The Dollar Sign symbol (“$”)
Lowercase “r” as in Romeo
Uppercase “T” as in Tango
The number “1”
The number “2”
The Left Parenthesis symbol (“(“)
The Right Square Bracket symbol (“]”)
Lowercase “f” as in Foxtrot

Array Conversions

Using the Array type provides you with complete control over display and usage. The output from this style is an array where each element is an object representing information about a single character of the input string. Using the Array style is more difficult but useful when the simple or verbose styles do not meet your needs.

The following example code presents a table with all of the values returned in the Array style: