Cyrillic Check
Home | News | Download | Development |
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.
Installation
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?Where
?-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/directory2Options:
-file | The next argument must be strongly path to file. |
-dir | The next argument must be strongly path to directory. |
-filelist | The 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. |
-dirlist | The 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. |
-filetype | The next argument must specify an expression in the Glob-style search for
files in a directory. The default is *.{php,phtml} |
-pattern | The next argument must specify a regular expression to search for symbols
in the code. By default, Cyrillic characters [À-ßà-ÿ]+ |
-svn-start-commit | This 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 ".*"
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:
- Open section Settings in TortoiseSVN, go to "Step Hook Scripts".
- Press the button "Add ...".
- In the dialog "Configure Hook Scripts" tune:
- "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.
- In the "Working Copy Path" should specify the path to your working copy.
- 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.
License: GNU LESSER GPL