Re: invalid byte sequence for encoding "UTF8": 0x00

From: "liuyuanyuan" <liuyuanyuangogo(at)gmail(dot)com>
To: "'Andreas Joseph Krogh-2 [via PostgreSQL]'" <ml-node+s1045698n5816732h11(at)n5(dot)nabble(dot)com>
Cc: <pgsql-admin(at)postgresql(dot)org>
Subject: Re: invalid byte sequence for encoding "UTF8": 0x00
Date: 2014-08-29 01:09:03
Message-ID: 001f01cfc325$d614fe20$823efa60$@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-jdbc

Thanks Andreas!

I like this clear answer!

My colleague and I have found about this in PostgreSQL source code, but we’re not so sure.

Thanks for your reply!

Regards!

Jasmine Liu

发件人: Andreas Joseph Krogh-2 [via PostgreSQL] [mailto:ml-node+s1045698n5816732h11(at)n5(dot)nabble(dot)com]
发送时间: 2014年8月28日 20:46
收件人: JasmineLiu
主题: Re: invalid byte sequence for encoding "UTF8": 0x00

På onsdag 27. august 2014 kl. 10:11:09, skrev Albe Laurenz <[hidden email]>:

JasmineLiu wrote:
> I've also got this problem while copy or insert data from MS SQL Server to
> PostgreSQL.
> SQLServer 2008 R2, encoding :GBK
> PostgreSQL 9.3.4, encoding:UTF8
>
> Rather than modify the column value in sql server,
> are there any other ways to solve this problem?
> Better to give me an examples.

You will never be able to insert a null character into a PostgreSQL database.
You can either modify the source data or change the data in transit.

This is not 100% true, but is true for text-fields. You can insert \0 into BYTEA columns.

Usually the \0 isn't important so you can do this in JAVA before inserting into PG:

someString.replace('\0', ' ') or someString.replaceAll("\0", "")

--

Andreas Joseph Krogh

CTO / Partner - Visena AS

Mobile: +47 909 56 963

[hidden email]

www.visena.com <https://www.visena.com>

<https://www.visena.com>

_____

If you reply to this email, your message will be added to the discussion below:

http://postgresql.1045698.n5.nabble.com/invalid-byte-sequence-for-encoding-UTF8-0x00-tp2172080p5816732.html

To unsubscribe from invalid byte sequence for encoding "UTF8": 0x00, click here <http://postgresql.1045698.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=2172080&code=bGl1eXVhbnl1YW5nb2dvQGdtYWlsLmNvbXwyMTcyMDgwfDU1NzU2MzQ0MQ==> .
<http://postgresql.1045698.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> NAML

Browse pgsql-admin by date

  From Date Subject
Next Message Saravanan.S 2014-08-29 05:46:28 Re: Table Partition
Previous Message Carlyle Miersma 2014-08-28 19:40:04 Windows PostgreSQL pgAgent Jobs Fail

Browse pgsql-jdbc by date

  From Date Subject
Next Message Albe Laurenz 2014-08-29 09:54:35 Re: invalid byte sequence for encoding "UTF8": 0x00
Previous Message Andreas Joseph Krogh 2014-08-28 12:45:23 Re: invalid byte sequence for encoding "UTF8": 0x00