Up until now, I have just used ISO-8859-1 for my mySQL data, but now we have started getting Russian orders, which cause the characters to show up as ? (not great when trying to print an invoice!)
So, I have been looking into converting the table into UTF8. My table structure is pretty simple:
DROP TABLE IF EXISTS `glinks_AdminSystemEBay`;
CREATE TABLE IF NOT EXISTS `glinks_AdminSystemEBay` (
`ebay_transaction_id` bigint(20) NOT NULL DEFAULT '0',
`paypal_trans_id_fk` varchar(200) DEFAULT NULL,
`payer_email` varchar(200) DEFAULT NULL,
`date_paid` varchar(200) DEFAULT NULL,
`shipping_paid` varchar(200) DEFAULT NULL,
`address` varchar(200) DEFAULT NULL,
`product_id_purchased` int(11) DEFAULT NULL,
`payment_amount` float DEFAULT NULL,
`total_amount` float DEFAULT NULL,
`been_added_to_system` int(11) DEFAULT NULL,
`sale_from` varchar(25) DEFAULT NULL,
`product_id` bigint(20) DEFAULT NULL,
`currency` varchar(10) DEFAULT NULL,
`paypal_fee` float DEFAULT NULL,
`units_sold` int(11) DEFAULT NULL,
`ebay_fees` float DEFAULT NULL,
`item_name` longtext,
`been_emailed` tinyint(4) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
When importing into it, I still got broken characters. I then came across this post:
http://www.shawnolson.net/a/946/unicode_data_with_php_5_and_mysql_41.html
I was not aware of the SET NAMES 'utf8'
being needed before. This fixed that "saving" part (running it before the query)
So now, you can see how it saves:
The problem I'm having now, is getting the data back out properly!
As a test, I am simply grabbing the record from the DB, and then doing a dumper:
print $IN->header;
use Data::Dumper;
print Dumper($invoice->{address});
All I get is:
$VAR1 = 'Matveenkova ,??????? ??????, ?. 21, ????. 2, ??. 90, ??????, 117208, Russian Federation';
I'm really baffled as to what I'm doing wrong! Can anyone shed some light?
UPDATE: Ok, so it actually looks like this issue is coming from our PDF generator (DOMPDF). It's fine in the HTML version:
...but the PDF version is broken:
I'll file a bug report with them, and see if they can help :)