From: Nicolas Boisselier Date: Fri, 2 Sep 2016 11:09:29 +0000 (+0200) Subject: bin/dbq-dir2sqlite ul X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=9f832103960254fc1f2c273c2e2bdc4d5a938940;p=nb.git bin/dbq-dir2sqlite ul --- diff --git a/bin/dbq-dir2sqlite b/bin/dbq-dir2sqlite index 37f6d95c..1dd30e27 100755 --- a/bin/dbq-dir2sqlite +++ b/bin/dbq-dir2sqlite @@ -121,8 +121,10 @@ for vars in $(dbq a=ls type='!sqlite' out=sh); do [ -w "${id}.db" ] || continue [ "$VERBOSE" -gt 0 ] && printf '%s : ' "$id" - dbq f=text a=db.dump db.type=sqlite db="$id" > "$TMP_DB" 2>/dev/null + rm -f "$TMP_DB" + dbq f=text a=db.dump db.type=sqlite db="$id" 2>/dev/null | sqlite3 "$TMP_DB" ret=$? + #file "$TMP_DB"; du -sh "$TMP_DB" if [ "$ret" != "0" -o ! -s "$TMP_DB" ];then [ "$VERBOSE" -gt 0 ] && echo "failed" continue diff --git a/etc/profile.d/functions b/etc/profile.d/functions index 729c9ed5..a09f45bb 100644 --- a/etc/profile.d/functions +++ b/etc/profile.d/functions @@ -106,7 +106,15 @@ realpath() { } ascii() { - perl -e 'binmode(STDOUT, ":utf8"); for(32..255){ print "$_:".chr($_)."\n"; }' + + if [ ! -t 0 ]; then + cat | perl -ne 'for (split("",$_)) { print sprintf("%3d",ord($_)).":$_\n"; }' + elif [ -n "$*" ]; then + perl -ne 'for (split("",$_)) { print sprintf("%3d",ord($_)).":$_\n"; }' $@ + else + perl -e 'binmode(STDOUT, ":utf8"); for(32..255){ print "$_:".chr($_)."\n"; }' + fi + } psmem() { diff --git a/lib/php/db.php b/lib/php/db.php index 93f494a3..182810e0 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -692,7 +692,7 @@ class Db extends nb { # Contruct DROP / CREATE foreach ($tables as $t) { - $sql = rtrim($t->create(true),';'); + $sql = rtrim($t->create(false),';'); $sql = str_replace(';CREATE',";\nCREATE",$sql); if ($drop = $this->type('sql.drop')) { diff --git a/lib/php/db/table.php b/lib/php/db/table.php index ed5c122e..03038b0b 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -134,7 +134,7 @@ Class Table extends nb { * return the sql to create the table build internaly * */ - public function create($from_sql=false) { + public function create($from_sql=true) { // String replace function $sql_replace_fct = $this->db()->type('sql.replace',false); @@ -785,6 +785,11 @@ Class Table extends nb { $count++; $call = null; + # Delete char 0 (from wordpress) + foreach ($row as $k=>$v) { + $row[$k] = str_replace(chr(0),'',$v); + } + if ($extras and !empty($this->db()->row_parse)) { $call = $this->db()->row_parse; $call($row); } @@ -798,15 +803,6 @@ Class Table extends nb { if (!isset($this->extras[$k])) $row[$k] = out::format($v); } - /* - */ - } elseif(0) { - //iconv(mb_detect_encoding($text, mb_detect_order(), true), "UTF-8", $text); - foreach ($row as $k=>$v) { - #if (!isset($this->extras[$k])) $row[$k] = mb_convert_encoding($v, "UTF-8"); - #if (!isset($this->extras[$k])) $row[$k] = preg_replace('/[\r\f]/','',$v); - } - } if ($extras and !empty($this->row_parse_post)) {