From 0e67880b97909c08021ef5fa1075082cfc9b6e26 Mon Sep 17 00:00:00 2001 From: Silvio Date: Thu, 1 Apr 2010 13:59:55 -0300 Subject: Charset support on PhpIsisDb --- classes/CinIsis.php | 3 +++ classes/PhpIsisDb.php | 25 ++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) (limited to 'classes') diff --git a/classes/CinIsis.php b/classes/CinIsis.php index 300bd61..77804c4 100644 --- a/classes/CinIsis.php +++ b/classes/CinIsis.php @@ -21,6 +21,9 @@ class CinIsis { * * @param $config * Alternative config file (defaults to 'config/config.yaml'). + * + * @todo + * Config check. */ function __construct($config = NULL) { if ($config == NULL) { diff --git a/classes/PhpIsisDb.php b/classes/PhpIsisDb.php index 169f832..b8f6566 100644 --- a/classes/PhpIsisDb.php +++ b/classes/PhpIsisDb.php @@ -50,6 +50,10 @@ class PhpIsisDb implements IsisDb { return FALSE; } + // Charset conversion. + array_walk_recursive($data, array('PhpIsisDb', 'charset')); + + // Return the result. return $this->tag(isis_fetch_array($results)); } @@ -90,6 +94,25 @@ class PhpIsisDb implements IsisDb { $data[$name] = $value; } } + return $data; - } + } + + /** + * Charset conversion. + * + * Converts a string from the database charset to UTF-8. + * + * @param $data + * String to be converted. + * + * @param $count + * Data index. Currently unused. + * + * @return + * String converted to UTF-8. + */ + function charset($data, $count) { + return iconv($data, $this->format['db']['charset'], 'UTF-8'); + } } -- cgit v1.2.3