Exemple #1
0
 public function convertToUTF8($data, $charset = "CP1252")
 {
     include_once $this->store->get_config("code") . "modules/mod_unicode.php";
     if (isset($data) && is_array($data)) {
         foreach ($data as $key => $val) {
             $data[$key] = $this->convertToUTF8($val, $charset);
         }
     } else {
         if (is_object($data)) {
             foreach ($data as $key => $val) {
                 $data->{$key} = $this->convertToUTF8($val, $charset);
             }
         } else {
             $data = unicode::convertToUTF8($charset, $data);
         }
     }
     return $data;
 }
Exemple #2
0
 public function next()
 {
     switch ($this->readMode) {
         case 'array':
             $result = current($this->csvArray);
             next($this->csvArray);
             break;
         default:
         case "fp":
             if (feof($this->fp)) {
                 $result = array();
             } else {
                 $result = fgetcsv($this->fp, $this->settings['bufferLength'], $this->settings['seperator'], $this->settings['quotation']);
                 if (is_array($result) && strtolower($this->settings['charset']) != "utf-8") {
                     if (!function_exists("iconv")) {
                         global $store;
                         include_once $store->get_config("code") . "modules/mod_unicode.php";
                         foreach ($result as $item => $resultItem) {
                             $result[$item] = unicode::convertToUTF8($this->settings["charset"], $result[$item]);
                         }
                     } else {
                         foreach ($result as $item => $resultItem) {
                             $result[$item] = iconv($this->settings["charset"], "utf-8", $result[$item]);
                         }
                     }
                 }
             }
             break;
     }
     if ($result && $this->keys && $this->settings['keySelection']) {
         $hashResult = array();
         foreach ($this->keys as $i => $key) {
             if (in_array($key, $this->settings['keySelection'])) {
                 $hashResult[$key] = $result[$i];
             }
         }
         $result = $hashResult;
     }
     $this->readLine = $result;
     return $result;
 }