简体   繁体   中英

Handling Special character while importing Excel to MySQL using perl

I have a excel file with special characters like é, non-breaking spaces, and bullets(•).
How to handle these type of special characters while importing from excel to MySQL database using perl module Spreadsheet::ParseExcel? Also i want to know default character set i have select for the creating the target table in the MySQL database.

Not knowing what encoding the Excel file has but I'm assuming utf-8. If you're not manipulating the data etc.

For your problem I'd assume you're just pulling the data from the fields and putting them in mysql. Then you want to make sure the encoding in MySQL is utf-8 (either set it as default or set "CHARSET=utf8" on the tables). Then in perl do:

$dbh->do('SET NAMES utf8');
$dbh->{'mysql_enable_utf8'} = 1;

and you should be pretty safe.

There's tons to read about perl and utf-8, both here and around the internet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM