PHP将unicode转换为十六进制

Rob*_*bus 4 php unicode hex

一个应用程序希望我插入字符串作为text encoded using hex values in proper coding.编码Unicode_No_Compression

例如,对于Sze?? siedem正确的HEX字符串0053007A0065015B0107002000730069006500640065006D,
?d?b?o= 01790064017A00620142006F
String with no special chars =0053007400720069006E0067002000770069007400680020006E006F0020007300700065006300690061006C002000630068006100720073

我尝试使用MySQL HEX()/ UNHEX()dechex()PHP,但无法弄清楚如何进行此转换.有任何想法吗?

dec*_*eze 10

我猜你正在查看UCS-2编码的十六进制版本.因此:

php > echo strtoupper(bin2hex(iconv('UTF-8', 'UCS-2', '?d?b?o')));
01790064017A00620142006F
Run Code Online (Sandbox Code Playgroud)

  • Little-endian与big-endian问题,取决于机器.尝试使用`UCS-2BE`来明确使用big-endian. (5认同)