Re: need help with utf-8

[email protected] (Felipe Gasper via dbi-users) Tue, 17 Dec 2024 07:31:02 -0500
Newsgroups perl.dbi.users
Message-ID <[email protected]>
--Apple-Mail-59D03F21-7E9C-45C6-863E-417FAB5B41D7
Content-Type: text/html;
	charset=utf-8
Content-Transfer-Encoding: quoted-printable

<html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=3D=
utf-8"></head><body dir=3D"auto"><div dir=3D"ltr"></div><div dir=3D"ltr">Res=
pectfully to Dan &amp; others, I don=E2=80=99t advocate adding =E2=80=9Cuse u=
tf8=E2=80=9D to existing code without a clear understanding of where your pr=
ogram=E2=80=99s decode &amp; encode points are.</div><div dir=3D"ltr"><br></=
div><div dir=3D"ltr">Check to see what DBD::Pg actually writes to the databa=
se. If it suddenly started encoding, that=E2=80=99s a breaking change that e=
ither was documented or should be reported upstream.</div><div dir=3D"ltr"><=
br><blockquote type=3D"cite">On Dec 16, 2024, at 17:13, Shaomei Liu &lt;sliu=
[email protected]&gt; wrote:<br><br></blockquote></div><blockquote type=3D=
"cite"><div dir=3D"ltr">=EF=BB=BF<div dir=3D"ltr">Hello,<br>very happy to fi=
nd this mailing list as it is my last resort!!<div>I have a project which us=
es DBI to write to postgres DB.</div><div>after upgrading from RHEL7 to RHEL=
8, the utf-8 character is not displayed properly in the DB. DB has correct u=
tf-8 encoding set.</div><div>for example, left double quotation mark&nbsp; &=
nbsp;=E2=80=9C&nbsp; is displayed as&nbsp;<span style=3D"background-color:rg=
b(31,31,31);color:rgb(204,204,204);font-family:Consolas,&quot;Courier New&qu=
ot;,monospace;font-size:14px;white-space:pre">=C3=A2\u0080\u009C</span>.</di=
v><div>You can use this link to check hex utf-8 bytes</div><div><a href=3D"h=
ttps://www.cogsci.ed.ac.uk/~richard/utf-8.cgi?input=3D%E2%80%9C&amp;mode=3Dc=
har">https://www.cogsci.ed.ac.uk/~richard/utf-8.cgi?input=3D%E2%80%9C&amp;mo=
de=3Dchar</a></div><div><br></div><div>below is the file <a href=3D"http://t=
estutf.pl">testutf.pl</a> which writes left double quotation mark&nbsp;

=E2=80=9C to the database. it also shows the query results from psql for bot=
h EL8 and EL7.<br><br>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3Dfile <a href=3D"http://t=
estutf.pl">testutf.pl</a>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<br>#!/usr/bin/perl<b=
r>use strict;<br>use warnings;<br>use DBI;<br>print "DBI version: $DBI::VERS=
ION\n";<br><br>my $db =3D "debugutf";<br>my $host =3D "db";<br>my $user =3D "=
postgres";<br>my $pass =3D "";<br>my $dbh =3D DBI-&gt;connect("DBI:Pg:dbname=
=3D$db;host=3D$host",$user,$pass);<br>my $sql =3D 'INSERT INTO table1 (title=
) VALUES (?)';<br>my $query =3D $dbh-&gt;prepare($sql);<br>my @values =3D ('=
=E2=80=9C');<br>$query-&gt;execute(@values);<br>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<=
br><br>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3Don RHEL8<br>#execute <a hre=
f=3D"http://testutf.pl">testutf.pl</a> which wrote =E2=80=9C to database on R=
HEL8<br><a href=3D"http://text.tac1.dev.bia-boeing.com">text.tac1.dev.bia-bo=
eing.com</a>&gt; ./<a href=3D"http://testutf.pl">testutf.pl</a><br>DBI versi=
on: 1.641<br><br>#from psql<br>debugutf=3D# select * from table1;<br>&nbsp; &=
nbsp; &nbsp;title<br>---------------<br>&nbsp;<font color=3D"#ff0000">=C3=A2=
\u0080\u009C&nbsp; =3D=3D=3D=3D=3D=3D=3D=3D=3D&gt;unexpected</font><br>(1 ro=
w)<br><br><br>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3Don RHEL7<br>#execute=
 <a href=3D"http://testutf.pl">testutf.pl</a> which wrote =E2=80=9C to datab=
ase on RHEL8<br><a href=3D"http://text.tac1.dev.bia-boeing.com">text.tac1.de=
v.bia-boeing.com</a>&gt; ./<a href=3D"http://testutf.pl">testutf.pl</a><br>D=
BI version: 1.627<br><br>#from psql<br>debugutf=3D# select * from table1;<br=
>&nbsp; &nbsp; &nbsp;title<br>---------------<br><font color=3D"#0000ff">&nb=
sp;=E2=80=9C&nbsp; &nbsp; &nbsp; &nbsp;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D&=
gt;expected</font><br>(1 row)</div><div><br></div><div>Any feedback is appre=
ciated.</div><div>thank you</div><div>Shirley</div></div>
</div></blockquote></body></html>=

--Apple-Mail-59D03F21-7E9C-45C6-863E-417FAB5B41D7--