将单字节字符串转换为双字节字符串 [英] Convert single byte string to double byte string

查看:456
本文介绍了将单字节字符串转换为双字节字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要字符串游戏转换游戏。这个字符串是一个日文双字节字符串。

I want the string Game to convert Game. This string is a Japanese double byte string.

可以使用PHP来实现吗?

Is it possible to achieve this using PHP? If so, how?

推荐答案

首先,游戏不是ASCII字符集,因此您可能需要设置页面内容类型标头以查看正确的输出:

First of all, Game is not ASCII charset, so you might need to set the page Content-type header to see a proper output:

header("Content-type: text/html; charset=utf-8");

然后您可以使用此功能转换它

Then you can convert it using this function

echo mb_convert_kana('Game', "R", 'UTF-8')

编辑:

对于MySQL,我找不到转换器做同样的操作。但是,您仍然可以在十六进制级别手动转换,例如,您可以这样获取单词游戏

For MySQL I couldn't find a converter to do the same. However, you can still convert it manually on the Hex level, for example, you can get the word Game like this

SELECT CHAR(0xefbca7, 0xefbd81, 0xefbd8d, 0xefbd85) as `Full Width`;

所以,我们可以在MySQL中编写一个映射函数,使用这个表格

So, we can just write a mapping function in MySQL that replaces the characters using this table

这篇关于将单字节字符串转换为双字节字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆