<?php
/**
 * cp1252_to_utf8.php
 *
 * converts a Windows-CP1252-encoded String to UTF8
 */

/*
 * converts a Windows-CP1252-encoded String to UTF8
 */
function cp1252_to_utf8($text) {
  
$buffer $text;
  
$cp1252 = array(
    
128 => "€"# euro sign
    
130 => "‚"# single low-9 quotation mark
    
131 => "ƒ"# latin small letter f with hook
    
132 => "„"# double low-9 quotation mark
    
133 => "…"# horizontal ellipsis
    
134 => "†"# dagger
    
135 => "‡"# double dagger
    
136 => "ˆ"# modifier letter circumflex accent
    
137 => "‰"# per mille sign
    
138 => "Š"# latin capital letter s with caron
    
139 => "‹"# single left-pointing angle quotation mark
    
140 => "Œ"# latin capital ligature oe
    
142 => "Ž"# latin capital letter z with caron
    
145 => "‘"# left single quotation mark
    
146 => "’"# right single quotation mark
    
147 => "“"# left double quotation mark
    
148 => "”"# right double quotation mark
    
149 => "•"# bullet
    
150 => "–"# en dash
    
151 => "—"# em dash
    
152 =>  "˜"# small tilde
    
153 => "™"# trade mark sign
    
154 =>  "š"# latin small letter s with caron
    
155 => "›"# single right-pointing angle quotation mark
    
156 => "œ"# latin small ligature oe
    
158 => "ž"# latin small letter z with caron
    
159 => "Ÿ" # latin capital letter y with diaeresis
    
);
  
$buffer_encoded utf8_encode($buffer);
  
  foreach(
$cp1252 as $ord => $encoded) {
      
$buffer_encoded=str_replace(utf8_encode(chr($ord)), $encoded$buffer_encoded);
  }
  return 
$buffer_encoded;


?>