参数中的PayPal IPN API和Unicode符号

时间:2014-11-15 00:35:21

标签: php unicode paypal paypal-ipn

我遇到了PayPal IPN API的奇怪问题。我在我的网站上设置了一个PHP脚本来处理客户付款。每次为我的服务付款时,PayPal IPN都会调用该脚本。反过来,脚本使用PayPal提供的信息为客户发送注册电子邮件。

此工作正常,除非PayPal用户的姓名不是英文。就像这笔付款(来自我的PayPal页面的截图),中文名称为:

enter image description here

以下内容取自PayPal的“Instant Payment Notification (IPN) history”,用于PayPal IPN生成的请求(已删除实际ID):

transaction_subject=&payment_date=01:22:55 Nov 11, 2014 PST&txn_type=web_accept&last_name=&residence_country=CN&item_name=service_name_here&payment_gross=1.00&mc_currency=USD&business=businessname@gmain.com&payment_type=instant&protection_eligibility=Ineligible&verify_sign=longidhere&payer_status=unverified&tax=0.00&payer_email=buyersemail@somewhere.com&txn_id=id_here&quantity=1&receiver_email=myemail@gmain.com&first_name=&payer_id=id_here&receiver_id=id_here&item_number=1&handling_amount=0.00&payment_status=Completed&payment_fee=0.08&mc_fee=0.08&shipping=0.00&mc_gross=1.00&custom=&charset=windows-1252&notify_version=3.8&ipn_track_id=some_id

处理名称的PHP脚本是:

$encoding_2_use = "utf-8";
$encoding_used = $_REQUEST['charset'];
$FirstName = mb_convert_encoding($_REQUEST['first_name'], $encoding_2_use, $encoding_used);
$LastName = mb_convert_encoding($_REQUEST['last_name'], $encoding_2_use, $encoding_used);

//Then I use $FirstName and $LastName to make up registration for the customer.

//And to compose an email
$msg = "Hello $FirstName $LastName:";

但是我对中文名字的看法是:

  

您好:

或者如果你通过Hex编辑器打开它我可以看到:

enter image description here

0x1A个字符,而不是中文名称的两个部分。

知道如何解决这个问题吗?

0 个答案:

没有答案