diff options
-rw-r--r-- | classes/BiblioIsisDb.php | 18 | ||||
-rw-r--r-- | classes/PhpIsisDb.php | 6 | ||||
-rw-r--r-- | tests/csv.php | 5 |
3 files changed, 26 insertions, 3 deletions
diff --git a/classes/BiblioIsisDb.php b/classes/BiblioIsisDb.php index d7fdd1c..81db3e7 100644 --- a/classes/BiblioIsisDb.php +++ b/classes/BiblioIsisDb.php @@ -90,6 +90,9 @@ class BiblioIsisDb implements IsisDb { // Tag results. $data = $this->tag($results); + // Charset conversion. + array_walk_recursive($data, array(__CLASS__, 'charset')); + // Return the result. return $data; } @@ -184,4 +187,19 @@ class BiblioIsisDb implements IsisDb { } return $value; } + + /** + * Charset conversion. + * + * Converts a string from the database charset to UTF-8. + * + * @param $data + * String to be converted. + * + * @return + * String converted to UTF-8. + */ + function charset(&$data) { + $data = iconv($this->format['db']['charset'], 'UTF-8', $data); + } } diff --git a/classes/PhpIsisDb.php b/classes/PhpIsisDb.php index 1f64075..50fdf49 100644 --- a/classes/PhpIsisDb.php +++ b/classes/PhpIsisDb.php @@ -131,7 +131,7 @@ class PhpIsisDb implements IsisDb { * @return * String converted to UTF-8. */ - function charset($data) { - return iconv($data, $this->format['db']['charset'], 'UTF-8'); - } + function charset(&$data) { + $data = iconv($this->format['db']['charset'], 'UTF-8', $data); + } } diff --git a/tests/csv.php b/tests/csv.php index 1d3c5cb..42e45f3 100644 --- a/tests/csv.php +++ b/tests/csv.php @@ -43,6 +43,11 @@ if ($isis->db) { // Format output. for ($n=1; $n <= $rows; $n++) { + // FIXME: fbe db corruption? + if ($n == 1494) { + continue; + } + $result = $isis->db->read($n); foreach ($format['fields'] as $field) { if (is_array($result[$field['name']])) { |