unset($opt['tables']);
}
+ # Encoding
+ if (isset($opt['encoding'])) {
+ self::$encoding = $opt['encoding'];
+ unset($opt['encoding']);
+ }
+
# Args into this
foreach ($opt as $k=>$v) $this->$k = $v;
+ #parent::__construct($opt);
+ #if(!is_scalar($opt['type'])) debug($opt['type']);
+ if (self::$encoding) out::$charset=self::$encoding;
# id
if (!empty($this->conf)) {
'exec' => array_merge(
[
'SET NAMES '.str_replace('utf-8','utf8',strtolower(Db::$encoding)),
+ #'SET NAMES '.str_replace(['utf-8','utf8'],['utf8mb4','utf8mb4'],strtolower(Db::$encoding)),
],
(Db::p('db.type') ? [
"/*!40103 SET TIME_ZONE='+00:00' */",
} else if (self::is_hash($data[0])) {
- $o['head_max_len'] = max(self::ar_map('strlen($a)',array_keys($data[0])));
+ $o['head_max_len'] = max(self::ar_map('mb_strlen($a)',array_keys($data[0])));
} elseif (is_array($data[0])) {
#debug($data);
- $o['head_max_len'] = max(self::ar_map('strlen($a)',$data[0]));
+ $o['head_max_len'] = max(self::ar_map('mb_strlen($a)',$data[0]));
}
}
# NB 10.04.16 if (!self::is_hash($row)) unset($o['head_max_len']);
-# NB 10.04.16 if (is_array($row) and count($row)>1) $o['head_max_len'] = strlen(count($row));
+# NB 10.04.16 if (is_array($row) and count($row)>1) $o['head_max_len'] = mb_strlen(count($row));
#if (!self::is_hash($row)) return out_yaml($row,$o);
# text
echo sprintf("%"
.(!empty($o['head_max_len']) ? '-'.($o['head_max_len']+1) : '')
."s: %s\n",$k,preg_replace('/\n(\w)/m'
- ,"\n".str_repeat(' ',(empty($o['head_max_len']) ? strlen($k) : $o['head_max_len']+1)+2).'\1'
+ ,"\n".str_repeat(' ',(empty($o['head_max_len']) ? mb_strlen($k) : $o['head_max_len']+1)+2).'\1'
,self::format($v))
);
}
$line = out_csv($row,$o);
$i = 0;
foreach (explode($o['sep'],$line) as $v) {
- $len = strlen($v);
+# NB 07.09.16 if (out::$charset == 'utf-8') {
+# NB 07.09.16 $len = strlen(utf8_decode($v));
+# NB 07.09.16 } else {
+# NB 07.09.16 $len = mb_strlen($v,out::$charset);
+# NB 07.09.16 }
+ $len = mb_strlen($v,out::$charset);
if (0
or empty($GLOBALS['_human_len'][$i])
or $len > $GLOBALS['_human_len'][$i]