convert_cyr_string() converts strings from one Cyrillic character set to another. The character sets to be converted are specified with a single character code. The codes correspond to the following character sets.
The presence of a null byte (\0) in the string halts the translation at that point.
// The first file is from phpMyAdmin (http://www.phpwizard.com/projects/phpMyAdmin/) $file_in = 'russian-koi8.inc.php3'; $file_out = 'russian-iso8859-5.inc.php3'; $fp = fopen($file_in, 'r') or die("Could not open file <i>$file_in</i> for reading."); // Read the entire contents of the file in one go $contents = fread($fp, filesize($file_in)) or die("Could not read the contents of file <i>$file_in</i>."); fclose($fp); // Convert the contents of the file from KOI8 to ISO8859-5 $contents = convert_cyr_string($contents, 'k', 'i'); // Write the converted contents out to another file $fp = fopen($file_out, 'w') or die("Could not open file <i>$file_out</i> for writing."); fputs($fp, $contents) or die("Could not write to file <i>$file_out</i>."); fclose($fp);
PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). The authors of this book have elected not to choose any options under the OPL. This online book was obtained from http://www.fooassociates.com/phpfer/ and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.