Changeset 6fa87f3 in github


Ignore:
Timestamp:
Nov 12, 2008 5:36:09 PM (5 years ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
e538b3d
Parents:
146977e
Message:

Improve charset encoding + remove BOM before parsing vcards

File:
1 edited

Legend:

Unmodified
Added
Removed
  • program/include/rcube_vcard.php

    rf45a174a r6fa87f3  
    173173    if ($encoding && $encoding != RCMAIL_CHARSET) { 
    174174      $data = rcube_charset_convert($data, $encoding); 
     175      $data = preg_replace(array('/^[\xFE\xFF]{2}/', '/^\xEF\xBB\xBF/', '/^\x00+/'), '', $data); // also remove BOM 
    175176    } 
    176177 
     
    410411    if (substr($string, 0, 3) == "\xEF\xBB\xBF") return 'UTF-8'; 
    411412 
    412     if ($enc = rc_detect_encoding($string)) 
     413    // use mb_detect_encoding() 
     414    $encodings = array('UTF-8', 'ISO-8859-1', 'ISO-8859-2', 'ISO-8859-3', 
     415      'ISO-8859-4', 'ISO-8859-5', 'ISO-8859-6', 'ISO-8859-7', 'ISO-8859-8', 'ISO-8859-9', 
     416      'ISO-8859-10', 'ISO-8859-13', 'ISO-8859-14', 'ISO-8859-15', 'ISO-8859-16', 
     417      'WINDOWS-1252', 'WINDOWS-1251', 'BIG5', 'GB2312'); 
     418 
     419    if (function_exists('mb_detect_encoding') && ($enc = mb_detect_encoding($string, join(',', $encodings)))) 
    413420      return $enc; 
    414421 
Note: See TracChangeset for help on using the changeset viewer.