#!/bin/bash

echo "TRUNCATE TABLE test" | psql alextest -h lab100 -U smoc
echo ""

# server db = UTF8
# client conn = UTF8
export PGCLIENTENCODING=UTF8
# client env
export LANG=zh_TW.UTF-8
export LC_ALL=zh_TW.UTF-8

# no convert
echo "s-utf8 c-utf8 txt-big5"
echo "insert into test(name)values('s-utf8 c-utf8 txt-big5');" | psql alextest -h lab100 -U smoc
psql alextest -h lab100 -U smoc < /root/s-utf8.c-utf8.txt-big5
echo ""
echo "s-utf8 c-utf8 txt-utf8"
echo "insert into test(name)values('s-utf8 c-utf8 txt-utf8');" | psql alextest -h lab100 -U smoc
psql alextest -h lab100 -U smoc < /root/s-utf8.c-utf8.txt-utf8

# convert
echo ""
echo "s-utf8 c-utf8 txt-big5toutf8"
echo "insert into test(name)values('s-utf8 c-utf8 txt-big5toutf8');" | psql alextest -h lab100 -U smoc
psql alextest -h lab100 -U smoc < /root/s-utf8.c-utf8.txt-big5toutf8

echo "#########################################################################"
echo "insert into test(name)values('#####################');" | psql alextest -h lab100 -U smoc

# server db = UTF8
# client conn = BIG5
export PGCLIENTENCODING=BIG5
# client env
export LANG=zh_TW.UTF-8
export LC_ALL=zh_TW.UTF-8

# no convert
echo "s-utf8 c-big5 txt-utf8"
echo "insert into test(name)values('s-utf8 c-big5 txt-utf8');" | psql alextest -h lab100 -U smoc
psql alextest -h lab100 -U smoc < /root/s-utf8.c-big5.txt-utf8
echo ""
echo "s-utf8 c-big5 txt-big5"
echo "insert into test(name)values('s-utf8 c-big5 txt-big5');" | psql alextest -h lab100 -U smoc
psql alextest -h lab100 -U smoc < /root/s-utf8.c-big5.txt-big5

# convert
echo ""
echo "s-utf8 c-big5 txt-utf8 to big5"
echo "insert into test(name)values('s-utf8 c-big5 txt-utf8 to big5');" | psql alextest -h lab100 -U smoc
psql alextest -h lab100 -U smoc < /root/s-utf8.c-big5.txt-utf8tobig5

Related posts 相關文章

作者

留言

撰寫回覆或留言

發佈留言必須填寫的電子郵件地址不會公開。