<?php /* ***** Thai (windows-874) to UTF-8 function ********************
* Copyright (c) 2005 Brian Huisman AKA GreyWyvern - v1.1
* PHP encoding converter from windows-874 to UTF-8
*
* Modified for PHP from the original Perl as taken from NexTrieve-0.41
* http://backpan.perl.org/authors/id/E/EL/ELIZABETH/NexTrieve-0.41.tar.gz
*
* Copyright (c) 1995-2003 Elizabeth Mattijsen <liz@dijkmat.nl>. All
* rights reserved.
* This program is free software; you can redistribute it and/or modify
* it under the same terms as Perl itself.
********************************************************************* */

function win874_2utf8($input) {
  static 
$windows874;

  if (!
count($windows874)) $windows874 = array(
    
'€''''''''''…''''''''',
    
'''''''''''''''‘''’''“',
    
'”''•''–''—''''''''''''',
    
''''' ''ก''ข''ฃ''ค''ฅ''ฆ''ง',
    
'จ''ฉ''ช''ซ''ฌ''ญ''ฎ''ฏ''ฐ''ฑ',
    
'ฒ''ณ''ด''ต''ถ''ท''ธ''น''บ''ป',
    
'ผ''ฝ''พ''ฟ''ภ''ม''ย''ร''ฤ''ล',
    
'ฦ''ว''ศ''ษ''ส''ห''ฬ''อ''ฮ''ฯ',
    
'ะ''ั''า''ำ''ิ''ี''ึ''ื''ุ''ู',
    
'ฺ''''''''''฿''เ''แ''โ''ใ',
    
'ไ''ๅ''ๆ''็''่''้''๊''๋''์''ํ',
    
'๎''๏''๐''๑''๒''๓''๔''๕''๖''๗',
    
'๘''๙''๚''๛''''''''');

  
$input preg_replace("/[\x81\x82\x83\x84\x86\x87\x88\x89\x8A\x8B\x8C\x8D\x8E\x8F\x90\x98\x99\x9A\x9B\x9C\x9D\x9E\x9F\xDB\xDC\xDD\xDE\xFC\xFD\xFE\xFF]/"" "$input);
  return 
preg_replace("/([\x80-\xFF])/e"'$windows874[ord($1) - 0x80]'$input);
?>