From: Nicolas Boisselier Date: Thu, 14 Dec 2017 03:57:54 +0000 (+0000) Subject: /tmp/nb.php X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=68eb990a9f9cc416e42c295a9c1e923220b24891;p=nb.git /tmp/nb.php --- diff --git a/lib/php/out.php b/lib/php/out.php index 2a573d22..5bf50e99 100644 --- a/lib/php/out.php +++ b/lib/php/out.php @@ -192,7 +192,12 @@ Class Out extends Nb { 'json' => [ 'enclose' => array('['.self::p('eol',NB_EOL),']'), - 'row' => function(&$o,&$row) { return json_encode($row); }, + 'row' => function(&$o,&$row) { +# NB 14.12.17 if (self::charset() == 'utf-8') foreach ($row as $k=>$v) { +# NB 14.12.17 if (is_scalar($v)) $row[$k] = utf8_encode($v); +# NB 14.12.17 } + return self::json_encode($row); + }, 'eol' => self::p('eol',NB_EOL), 'rec' => ',', ], @@ -249,7 +254,7 @@ Class Out extends Nb { '', ],var_export($v,true))); return var_export($v,true); - return is_scalar($v) ? $v : json_encode($v); + return is_scalar($v) ? $v : self::json_encode($v); } public static function type_call($k,&$o,&$row=[]) { @@ -352,7 +357,7 @@ Class Out extends Nb { foreach ($tmp_row as $k => $v) { if (!isset($o['length'][$k])) $o['length'][$k] = 0; if (!empty($o['quote'])) $tmp_row[$k] = $v = self::quote($v,$o['quote'],isset($o['quote_escape']) ? $o['quote_escape'] : null); - $l = mb_strlen($v,self::$charset); + $l = mb_strlen($v,self::charset()); if ($l > $o['length'][$k]) $o['length'][$k] = $l; } @@ -377,11 +382,11 @@ Class Out extends Nb { return $ret; } - public static function row_end($o) { - bye('OBSOLETE'); - if (isset($o['rec'])) echo $o['rec']; - if (isset($o['eol'])) echo $o['eol']; - } +# NB 14.12.17 public static function row_end($o) { +# NB 14.12.17 bye('OBSOLETE'); +# NB 14.12.17 if (isset($o['rec'])) echo $o['rec']; +# NB 14.12.17 if (isset($o['eol'])) echo $o['eol']; +# NB 14.12.17 } public static function end(&$o) { #if (isset($o['end'])) echo $o['end']($o);