| @@ -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,16 +78,14 @@ | ||
| 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++ ) { |
| 85 | 87 | $default_type = $i == 0 ? 'string' : 'number'; |
| 86 | - | |
| 87 | - $labels[ $i ] = $this->toUTF8( $labels[ $i ] ); | |
| 88 | - | |
| 89 | 88 | $this->_series[] = array( |
| 90 | 89 | 'label' => $labels[ $i ], |
| 91 | 90 | 'type' => isset( $types[ $i ] ) ? $types[ $i ] : $default_type, |
| 92 | 91 | ); |
| @@ -107,9 +106,12 @@ | ||
| 107 | 106 | protected function _get_file_handle( $filename = false ) { |
| 108 | 107 | // set line endings auto detect mode |
| 109 | 108 | ini_set( 'auto_detect_line_endings', true ); |
| 110 | 109 | // open file and return handle |
| 111 | - 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' ); | |
| 112 | 114 | } |
| 113 | 115 | |
| 114 | 116 | /** |
| 115 | 117 | * Fetches information from source, parses it and builds series and data arrays. |