开发者

MySQL - storing characters in different language or special symbols

开发者 https://www.devze.com 2022-12-24 08:53 出处:网络
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 da

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) D开发者_JS百科EFAULT 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?


Yes. Change charset to UTF8.

0

精彩评论

暂无评论...
验证码 换一张
取 消