home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / tsw / TSW_3.4.0.exe / Apache2 / admin / Windows-1251.inc < prev    next >
Encoding:
Text File  |  2003-06-29  |  2.0 KB  |  81 lines

  1. <?php
  2. /////////////////////////////
  3. //    Windows-1251.inc
  4. //    (C)2002 Ryo Chijiiwa <Ryo@IlohaMail.org>
  5. //    CyrLize function by Yozh <yozh.com.ua>
  6. //        
  7. //    Description:
  8. //        Encoding library for the Windows-1251 charset (Cyrillic).
  9. //    Comments:
  10. //        The LangConvert function in this charset library, unlike others,
  11. //        uses the third parameter to determine how to convert.    
  12. //
  13. //    This file is part of IlohaMail. IlohaMail is free software released 
  14. //    under the GPL license.  See enclosed file COPYING for details, or 
  15. //    see http://www.fsf.org/copyleft/gpl.html
  16. ////////////////////////////
  17.  
  18. include_once("../include/qp_enc.inc");
  19.  
  20. function LangIs8Bit($string){
  21.     $len = strlen($string);
  22.     for ($i=0; $i < $len; $i++)
  23.         if (ord($string[$i])>=128) return true;
  24.     
  25.     return false;
  26. }
  27.  
  28. function CyrLize ($string, $cset) {
  29.     $charset=strtolower($cset);
  30.     if ($charset=="koi8-r") {
  31.         $string=convert_cyr_string($string, "k", "w");
  32.         $c=true;
  33.     }else if ($charset=="iso8859-5") {
  34.         $string=convert_cyr_string($string, "i", "w");
  35.         $c=true;
  36.     }else if ($charset=="x-cp866") {
  37.         $string=convert_cyr_string($string, "a", "w");
  38.         $c=true;
  39.     }else if ($charset=="x-mac-cyrillic") {
  40.         $string=convert_cyr_string($string, "m", "w");
  41.         $c=true;
  42.     }else if ($charset=="windows-1251") {
  43.         $string=$string;
  44.         $c=true;
  45.     }
  46.  
  47.     return $string;
  48. }
  49.  
  50. function LangConvert($string, $charset, $from_charset){
  51.     return CyrLize($string, $from_charset);
  52. }
  53.  
  54. function LangEncodeSubject($input, $charset){
  55.     $words = explode(" ", $input);
  56.     if ( count($words) > 0){
  57.         while ( list($k, $word) = each($words) ){
  58.             if (LangIs8Bit($word)) $words[$k] = "=?".$charset."?Q?".qp_enc($word, 76)."?=";
  59.         }
  60.         $input = implode(" ", $words);
  61.     }
  62.     return $input;
  63. }
  64.  
  65. function LangEncodeMessage($input, $charset){
  66.     $message=$input;
  67.     
  68.     $result["type"]="Content-Type: text/plain; charset=".$charset."\r\n";
  69.     $result["encoding"]="Content-Transfer-Encoding: quoted-printable\r\n";
  70.     $result["data"] = qp_enc($message, 78);
  71.         
  72.     return $result;
  73. }
  74.  
  75. include_once("../lang/common.inc");
  76.  
  77. function LangWrap($str){
  78.     return wordwrap($str);
  79. }
  80. ?>
  81.