tags:

views:

101

answers:

1

I need to create a table in MySQL which stores the different currency symbols of the different countries in the world. These symbols are in different languages and are not getting inserted into the database and it throws errors like

incorrect string value xd8\x8b

Sample data is:

insert into country ( country_name, currency_name, currency_code, currency_symbol) values 
('Afghanistan','Afghanis','AFN',' ؋'),
('Aruba','Guilders','AWG',' ƒ'),
('Azerbaijan','New Manats','AZN',' ман'),
('Bulgaria','Leva','BGN',' лв'),
('Costa Rica','Colón','CRC',' ₡'),
('Cuba','Pesos','CUP',' ₱'),
('Cyprus','Euro','EUR',' €'),
('Czech Republic','Koruny','CZK',' Kč'),
('Ghana','Cedis','GHC',' ¢'),
('Iran','Rials','IRR',' ﷼'),
('Israel','New Shekels','ILS',' ₪'),
('Japan','Yen','JPY',' ¥'),
('Kazakhstan','Tenge','KZT',' лв'),
('Korea','Won','KPW',' ₩'),
('Laos','Kips','LAK',' ₭'),
('Macedonia','Denars','MKD',' ден'),
('Mongolia','Tugriks','MNT',' ₮'),
('Nigeria','Nairas','NGN',' ₦'),
('Pakistan','Rupees','PKR',' ₨'),
('Russia','Rubles','RUB',' руб'),
('Vietnam','Dong','VND',' ₫'),
('Yemen','Rials','YER',' ﷼');

I am using MySQL 5.1.22 and this is the current table structure:

CREATE TABLE `country` (
  `country_id` int(11) NOT NULL AUTO_INCREMENT,
  `country_name` varchar(100) DEFAULT NULL,
  `currency_name` varchar(100) DEFAULT NULL,
  `currency_code` varchar(20) DEFAULT NULL,
  `currency_symbol` varchar(20) DEFAULT NULL,
  `date_created` datetime DEFAULT NULL,
  `last_modified` datetime DEFAULT NULL,
  PRIMARY KEY (`country_id`)
) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=latin1;

Is it just a matter of changing the CHARSET to something else?

+2  A: 

Yes. Change charset to UTF8.

Col. Shrapnel
Thanks - I created a new table with CHARSET set to UTF8 - still certain lines are not being inserted like the currency of afghanistan, azerbaijan, bulgaria, costa rica to name a few.
Gublooo
@Gublooo these symbols must be in utf-8 too and you must send `SET NAMES utf8` query to the server right after connect.
Col. Shrapnel
@Col Shrapnel - so your saying - for example to insert Yen symbol - I have to enter the UTF-8 value like 0xC2,0xA5 - hmmm if thats the case - when I retrieve this data and to display in browser do I need to do anything special or will it display as Yen symbol - thanks
Gublooo
sorry my bad - I changed the table charset to UTF8 but the columns were still latin1 - after changing them I am able to insert the symbols. Thanks for your help
Gublooo