Cyrillic Check

Visually, it is difficult to distinguish the letters of one language from another. For example, the word "ontract". The first letter in it - the Cyrillic "", not the English "c". This was difficult to guess because the fact that word in the English language.

This problem is especially actual in programming. omputers does not understand the mistake. If the name of the variable $ontract recorded with an error, at best get an error during compile time.

PHP interpreter allows you to use variables and functions, with the names of the national language.
For example:

$ = '';
echo $;

The error in the variable name $ontract not be immediately apparent and it will be difficult to detect. Perhaps the code with such a variable would work, but only as long as the user's locale same as author's code.

The program "Cyrillic Check" helps to identify the use of Cyrillic characters in the code PHP. Exception: comments and quoted strings. The result is represented graphically window as a list of errors.


The program requires no installation. Download and unzip it.

For use in Windows, run the executable file "cyrchk.exe". The executable file includes an interpreter Tcl/Tk, so the size of the program is pretty big. You can setup interpreter Tcl/Tk separately and used to run the script "cyrchk.tcl".

For use in Linux or other Unix-like environments, required pre-install interpreter Tcl/Tk. To run the script to use "cyrchk.tcl".

The application's default encoding is cp1251.

Usage with command line

cyrchk ?-option value? ?path?
?-option value?optional parameter option and value;
?path?optional path to a file or directory for testing.

If "path" the path to the file will be checked by the file specified. If "path" the path to the directory will be checked all the files PHP, found in this directory and in all subdirectories. The number of parameters does not matter. Options can be combined.
For example:

cyrchk path/to/file1 path/to/file2 path/to/directory1 path/to/directory2
-fileThe next argument must be strongly path to file.
-dirThe next argument must be strongly path to directory.
-filelistThe next argument must be strongly path to file, which contains a list of files for checking. Each path is on a separate line in the file.
-dirlistThe next argument must be strongly path to file, which contains a list of directories for checking. Each path is on a separate line in the file.
-filetypeThe next argument must specify an expression in the Glob-style search for files in a directory. The default is *.{php,phtml}
-patternThe next argument must specify a regular expression to search for symbols in the code. By default, Cyrillic characters [--]+
-svn-start-commitThis argument is used to integrate with TortoiseSVN on hook Start-commit (see Integration with svn). This argument must be the last in the argument list. After it expected arguments PATH, MESSAGEFILE, CWD, added svn client automatically.

Possible to use multiple identical options. They are applied from left to right and act until overridden again.
For example:

cyrchk file1 -pattern "[-]+" file2 -pattern "[-]+" file3 -pattern ".*"
Here to test file1 will be used a pattern by default.
To test file2 pattern "[-]+" (Cyrillic letters in lower case).
To test file3 pattern "[-]+" (Cyrillic letters in upper case).
The last pattern ".*" (search for any character) is not used during testing.

Integration with svn

If you are using SVN in the development, it would be cool to check code for errors before every commit. To do this, you should:

  1. Open section Settings in TortoiseSVN, go to "Step Hook Scripts".
  2. Press the button "Add ...".
  3. In the dialog "Configure Hook Scripts" tune:
    1. "Hook Type" select "Start Commit Hook". This hook is called before a demonstration of the main dialogue commit to SVN. Use other types of hooks meaningless - they operate too late.
    2. In the "Working Copy Path" should specify the path to your working copy.
    3. In the "Command Line To Execute", enter the command. In this case - a path to cyrchk.exe. After cyrchk.exe can specify the required command line options. The latter should be mandatory option -svn-start-commit. After this argument are expected to PATH, MESSAGEFILE, CWD, added svn client automatically.

Author: maovrn