I have a value in MySQL that contains an apostrophe (’
) and an ellipsis (...
):
$ /bin/echo "select alias from url_alias where source = 'node/12024'" | \
mysql --skip-column-names -D cat36ia_d7prod
Output:
forum/technical-discussion/nagging-questions-i’ve-been-too-embarrassed-ask…
When I retrieve the value with Perl DBI
and DBD::mysql
, the value has been changed:
$ perl -MDBI -MDBD::mysql -e
'$dbh=DBI->connect( "DBI:mysql:database=my_db",nick );
$v=$dbh->selectrow_array(qq|select alias from url_alias where source = "'node/12024'"|);
print "$v\n";'
Output:
forum/technical-discussion/nagging-questions-i?ve-been-too-embarrassed-ask?
Why is Perl doing this? Can I override it?
Tell Perl how to encode the output.
use open ':std', ':encoding(UTF-8)';
Get the data from the database as text by using
DBI->connect("DBI:mysql:database=my_db", $user, $pass, {
mysql_enable_utf8 => 1,
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With