isCtrl() (Simulated functionality)

Check if a character is a control code.

Property/method value type:Boolean primitive

This is a function normally found in the C language. However it is useful to script developers as well and may be available in some implementations as an extension to the ECMA standard functionality.

This function tests to see if a character is a control code. It will return true for any character in the following set:

ValueCharacterMeaning
01<ctrl-A>SOH
03<ctrl-C>ETX
04<ctrl-D>EOT
05<ctrl-E>ENQ
06<ctrl-F>ACK
07<ctrl-G>BEL
08<ctrl-H>BS
09<ctrl-I>HT
0A<ctrl-J>LF
0B<ctrl-K>VT
0C<ctrl-L>FF
0D<ctrl-M>CR
0E<ctrl-N>SO
0F<ctrl-O>SI
10<ctrl-P>DLE
11<ctrl-Q>DC1
12<ctrl-R>DC2
13<ctrl-S>DC3
14<ctrl-T>DC4
15<ctrl-U>NAK
16<ctrl-V>SYN
17<ctrl-W>ETB
18<ctrl-X>CAN
19<ctrl-Y>EM
1A<ctrl-Z>SUB
1B<ctrl-[>ESC
1C<ctrl-\>FS
1D<ctrl-]>GS
1E<ctrl-^>RS
1F<ctrl-_>US
7F-DEL

Strictly speaking, this function should be coded to be aware of locale specific issues. You may want to take the example simulation provided here and modify it to your own needs to support that. This is just a basic working example.

Example code:

   // Test for control codes

   function isCtrl(aChar)

   {

      myCharCode = aChar.charCodeAt(0);

   

      if(((myCharCode > -1) && (myCharCode <  32)) ||

        ((myCharCode == 127)))

      {

         return true;

      }

   

      return false;

   }

See also:Character handling, Character testing, Control character, Enquiry functions, Letter