Digioso has asked for the wisdom of the Perl Monks concerning the following question:
The code tag seems to be having problems displaying the special characters. But I guess you get the idea.#!/usr/bin/perl -w use strict; use warnings; use Encode; use DBI; use feature 'unicode_strings'; binmode(STDOUT, ":utf8"); my $db = "..."; my $user = "..."; my $pw = '...'; my $host = "..."; my $options = {RaiseError => 1, AutoCommit => 1, mysql_enable_utf8 => +1}; my $dbh = DBI->connect("DBI:mysql:$db:$host", $user, "$pw", $options) +|| die "Could not connect to database!"; my $sql = 'select post_id, post_text from phpbb_posts where post_id = +24358'; my $sth = $dbh->prepare($sql); $sth->execute() or die "Error: $DBI::errstr"; my ($id, $text) = $sth->fetchrow_array; print "id: $id text: $text"; $text =~ s/├â┬ñ/ä/g; $text =~ s/├â┬Â/ö/g; $text =~ s/├â┼©/ß/g; $text =~ s/├â┬╝/ü/g; print "\nid: $id text: $text";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Convert special characters in UTF8 (layers)
by tye (Sage) on Jun 08, 2016 at 19:21 UTC | |
|
Re: Convert special characters in UTF8
by afoken (Chancellor) on Jun 08, 2016 at 19:08 UTC | |
by Digioso (Sexton) on Jun 08, 2016 at 19:19 UTC | |
by afoken (Chancellor) on Jun 08, 2016 at 19:59 UTC | |
by Digioso (Sexton) on Jun 08, 2016 at 20:11 UTC |