NAME v1.14 - CGI script to convert on-the-fly html pages across cyrillic charsets


Many Russia WWW servers are based on modified APACHE so, that different encodings are returned when clients connect to different server ports or to different subdomains. This is convenient for servers in Russia, but cannot be used abroad for Web sites using virtual servers or just having some space at an Internet provider's server. The following approach solves the problem by using one CGI script without any changes in WWW server software.

Those are features:


  1. Put the script in your cgi-bin directory.

  2. Edit the script to set script parameters to your configuration

  3. Refer to the script as: to be translated.

    1. TAB is one of the above encodings

    2. TAB can also also be of form 'fromcode-tocode' for explicit definition of the original file encoding.

    3. URL is absolute URL from the server root (Don't forget to set $path in or full URL like

All relative references from this page to other WEB pages will be also translated through the same code table (isn't supported yet for full URLs).

Source encoding is determined by the following algorithm. The first matching rule from this list is selected.

  1. If TAB specified by src-dst form, src is the source encoding.

  2. If Metatag like: <META HTTP-EQUIV=``Content-Type'' CONTENT=``text/plain; charset=win''> is present its charset is used. The tag is updated during translation by replacing source encoding by the destination one.

  3. Default encoding is taken from variable $defcode in


It is recommended that you put <META HTTP-EQUIV=``Content-Type'' ...> on all your pages, and choose only destination encoding in urls. Do not worry for old buggy browsers which can't display correctly pages with this metatag NOCS encoding converts page to koi8 and deletes the metatag.


If you use APPACHE you can add the lines similar to those to your webserver configuration files:

 ScriptAlias /koi8       /home/www/neystadt/cgi-bin/
 ScriptAlias /win        /home/www/neystadt/cgi-bin/
 ScriptAlias /dos        /home/www/neystadt/cgi-bin/
 ScriptAlias /mac        /home/www/neystadt/cgi-bin/
 ScriptAlias /iso        /home/www/neystadt/cgi-bin/
 ScriptAlias /utf8       /home/www/neystadt/cgi-bin/
 ScriptAlias /vol        /home/www/neystadt/cgi-bin/
 ScriptAlias /lat        /home/www/neystadt/cgi-bin/
 ScriptAlias /nocs       /home/www/neystadt/cgi-bin/

From now you will be able to translate urls like simply by prefixing the url with encoding: or

Note that automatically finds index.html if directory names is given (like in example above). The index file name can be changed by $IndexFileName parameter in the script.


To translate from Windows-1251 to KOI8: 

To translate output of the script from its default encoding to KOI8: 


This script requires the LWP, Convert::Cyrillic and HTTP::Headers::UserAgent modules available from CPAN or at

All UNIXes, Windows NT