In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you php how to achieve ucs2 coding, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Php to achieve ucs2 coding methods: 1, to create a PHP example file; 2, through the "function Ucs2Code ($str,$encode=" UTF-8 ") {.}" method to achieve ucs2 coding.
This article operating environment: Windows7 system, PHP7.1 version, Dell G3 computer.
PHP implements UCS2 Encoding and Decoding Encoding when sending SMS messages
The code is as follows:
/ * @ Method Ucs2Code UCS2 Encoding * @ Param $str input string * @ Param $encod input string Encoding Type (UTF-8,GB2312,GBK) * @ Return returns the encoded string * / function Ucs2Code ($str,$encode= "UTF-8") {$jumpbit=strtoupper ($encode) = 'GB2312'?2:3;// hops $strlen=strlen ($str); / / string length $pos=0;// position $buffer=array (); for ($pos=0) Pos=0xa1) {/ / 0xa1 (161Chinese character coding starts $tmpChar=substr ($str,$pos,$jumpbit); $pos+=$jumpbit;} else {$tmpChar=substr ($str,$pos,1); + + $pos;} $buffer [] = bin2hex (iconv ("UTF-8", "UCS-2", $tmpChar));} return strtoupper (join ("", $buffer)) } / * @ Method unUcs2Code UCS2 Decoding * @ Param $str input string * @ Param $encod input string Encoding Type (UTF-8,GB2312,GBK) * @ Return returns the decoded string * / function unUcs2Code ($str,$encode= "UTF-8") {$strlen=strlen ($str); $step=4;$buffer=array (); for
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.