CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Encoding issue from DBI to string

 



ev0lution37
Novice

Jan 3, 2013, 8:20 AM

Post #1 of 4 (3325 views)
Encoding issue from DBI to string Can't Post

I'm pretty stumped. I'm pulling from a MySQL database using DBI, however I'm getting junk when I dump it to an array. Here's the code:


Code
  
my $dbh = DBI->connect("DBI:mysql:$db_name1:$db_host1:$db_port1","$db_user1","$db_pw1", {RaiseError => 1, PrintError => 0, mysql_enable_utf8 => 1, ChopBlanks =>0});

$log->debug("Running SQL Select statement: $sqlselect" . "\n");

my $RowSet = $dbh->selectall_arrayref("SELECT * FROM CollectionDB.ISIS WHERE SourceID = '$PassedSource' ORDER BY ObjectKey DESC");


Now, after that I set each element of the array to a set of strings, then run data_string_desc on them. This is the result:


Code
artTitle is ?????? ?? ??? ???? ???? ???? 
Encoding test on Title results: UTF8 off, ASCII, 28 characters 28 bytes


I'm not sure how, even with UTF-8 enabled while DBI is connecting to the DB and UTF-8 set for every configuration on the database itself, the string is still appearing as ASCII. I need the UTF-8 because a majority of the data I'm bringing in is multibit (Chinese, Arabic, etc..)

Thanks in advance for any insight you can providE!


wickedxter
User

Jan 12, 2013, 9:00 AM

Post #2 of 4 (2816 views)
Re: [ev0lution37] Encoding issue from DBI to string [In reply to] Can't Post

Do u have the module:

Code
use utf8;

at the top of ur script?


7stud
Enthusiast

Jan 14, 2013, 11:10 PM

Post #3 of 4 (2700 views)
Re: [wickedxter] Encoding issue from DBI to string [In reply to] Can't Post


In Reply To
Do u have the module:

Code
use utf8;

at the top of ur script?

Do you spy any utf8 characters in the op's code?


(This post was edited by 7stud on Jan 14, 2013, 11:11 PM)


ev0lution37
Novice

Jan 15, 2013, 5:58 AM

Post #4 of 4 (2678 views)
Re: [7stud] Encoding issue from DBI to string [In reply to] Can't Post

Thanks for the replies. I actually did manage to get this resolved. In the end, it ended up being some weird issue with the version of Perl I was using.

Unfortunately, almost everything else in the workflow was dependent on the first version of Perl. Had to end up using two separate instances of it. Kind of a pain, but it's working.

Thanks again!

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives