| @@ -61,8 +61,9 @@ | ||
| 61 | 61 | */ |
| 62 | 62 | private function _fetchSeries( &$handle ) { |
| 63 | 63 | // read column titles |
| 64 | 64 | $labels = fgetcsv( $handle, 0, VISUALIZER_CSV_DELIMITER, VISUALIZER_CSV_ENCLOSURE ); |
| 65 | + $labels = array_map( 'utf8_encode', $labels ); | |
| 65 | 66 | // read series types |
| 66 | 67 | $types = fgetcsv( $handle, 0, VISUALIZER_CSV_DELIMITER, VISUALIZER_CSV_ENCLOSURE ); |
| 67 | 68 | |
| 68 | 69 | if ( ! $labels || ! $types ) { |
| @@ -77,8 +78,9 @@ | ||
| 77 | 78 | $handle = $this->_get_file_handle(); |
| 78 | 79 | |
| 79 | 80 | // re read the labels and empty types array |
| 80 | 81 | $labels = fgetcsv( $handle, 0, VISUALIZER_CSV_DELIMITER, VISUALIZER_CSV_ENCLOSURE ); |
| 82 | + $labels = array_map( 'utf8_encode', $labels ); | |
| 81 | 83 | $types = array(); |
| 82 | 84 | } |
| 83 | 85 | |
| 84 | 86 | for ( $i = 0, $len = count( $labels ); $i < $len; $i++ ) { |
| @@ -104,9 +106,12 @@ | ||
| 104 | 106 | protected function _get_file_handle( $filename = false ) { |
| 105 | 107 | // set line endings auto detect mode |
| 106 | 108 | ini_set( 'auto_detect_line_endings', true ); |
| 107 | 109 | // open file and return handle |
| 108 | - return fopen( $filename ? $filename : $this->_filename, 'rb' ); | |
| 110 | + $fc = iconv( 'ISO-8859-1', 'utf-8', file_get_contents( $filename ? $filename : $this->_filename ) ); | |
| 111 | + $tmp = tempnam( sys_get_temp_dir(), rand() ); | |
| 112 | + file_put_contents( $tmp, $fc ); | |
| 113 | + return fopen( $tmp, 'rb' ); | |
| 109 | 114 | } |
| 110 | 115 | |
| 111 | 116 | /** |
| 112 | 117 | * Fetches information from source, parses it and builds series and data arrays. |