Perl: need help on a character encoding/decoding issue
Budget: $10 – $30 CAD
I send text messages using Net::SMPP and it works great when using basic utf8 but I run into an issue when trying to send other accented characters such as "ê". When doing so I actually need to use UCS-2.
Ref: https://community.sinch.com/t5/SMS-365-enterprise-service/Handling-Special-Characters/ta-p/1137
Here is an example that works well, all characters are received properly:
$fred = 'éêcole';
$fred = decode('utf-8', $fred);
$fred = encode('utf-16', $fred);
$resp_pdu = $short_smpp->submit_sm(
source_addr_ton => 0x00,
source_addr_npi => 0x01,
source_addr => $didnb,
dest_addr_ton => 0x01,
dest_addr_npi => 0x01,
destination_addr => $number,
data_coding => 0x08,
short_message => $fred
*** However, if the first line is replaced by some code that gathers the data from the database, it doesnt work, even though I open it correctly and that it displays well:
$dbh->{'mysql_enable_utf8'}=1;
$dbh->do("set NAMES 'utf8'");
The table definition is also utf8.
*** I need someone to guide me but you cant have access to the code, you would need to help me through chat or screen share.
Thank you
Ref: https://community.sinch.com/t5/SMS-365-enterprise-service/Handling-Special-Characters/ta-p/1137
Here is an example that works well, all characters are received properly:
$fred = 'éêcole';
$fred = decode('utf-8', $fred);
$fred = encode('utf-16', $fred);
$resp_pdu = $short_smpp->submit_sm(
source_addr_ton => 0x00,
source_addr_npi => 0x01,
source_addr => $didnb,
dest_addr_ton => 0x01,
dest_addr_npi => 0x01,
destination_addr => $number,
data_coding => 0x08,
short_message => $fred
*** However, if the first line is replaced by some code that gathers the data from the database, it doesnt work, even though I open it correctly and that it displays well:
$dbh->{'mysql_enable_utf8'}=1;
$dbh->do("set NAMES 'utf8'");
The table definition is also utf8.
*** I need someone to guide me but you cant have access to the code, you would need to help me through chat or screen share.
Thank you
Related categories:
Perl