Cyrillic encoding

Summary

Notebooks created using eastern European keyboards on a Windows machine in versions of Mathematica prior to 4.1 will not display properly in Mathematica 4.1. The problem exists because of the character encodings that were used in earlier versions of Mathematica. This notebook defines a function which will convert the old notebook encodings over to the new format. Be aware that the converted notebooks will not run correctly in Mathematica 4.0 or earlier.

The functions

First you need to evaluate the following cell.

ReencodeCharacter[c_String, oldEncoding_String, newEncoding_String] := 
    Module[{oldEncodeChar = ToCharacterCode[c, oldEncoding]}, 
      If[oldEncodeChar === {None}, c, 
        FromCharacterCode[oldEncodeChar, newEncoding]]];
SetAttributes[ReencodeCharacter, Listable];
ReencodeString[str_String, oldEncoding_String, newEncoding_String] := 
    StringJoin[ReencodeCharacter[Characters[str], oldEncoding, 
newEncoding]];
ReencodeNotebook[fname_String, oldEncoding_String, newEncoding_String] := 
    Module[{nb = Get[fname]}, RenameFile[fname, fname <> ".orig"]; 
      nb = nb /. {x_String -> ReencodeString[x, oldEncoding, 
newEncoding]}; 
      Put[nb, fname]; fname];

Using the function

In a Mathematica session with no files open, run the following command in an untitled notebook:

  ReencodeNotebook["filename", "WindowsANSI", "WindowsCyrillic"]

where "filename" is the *fully qualified* pathname to the notebook. The program will leave the original version of the notebook in "filename.orig", and write the newly encoded notebook to "filename". (You can use the menu command Input/GetFilePath to fill the first argument.)