创建数据库字符集为utf8
网站编辑2023-06-21 11:11:45452
- 使用MySQL内置函数cURL,传入字符集为utf8:

use MYSQLClientStringsCURL;
use MYSQLClientScriptCURLBasicConfig;
use MYSQLClientScriptBasicConfigSimpleConfig;
- 创建MySQL服务端:
CURL localhost 5555;
- 创建MySQL客户端:
CURL localhost 5555;
完整示例代码:
```
!/bin/bash
创建MySQL连接
client = new MySQLConnector();
创建字符串缓冲区
text = client.getConnectionText(); charset = client.getBinaryString("utf8");
获取字符串
string = text.getBytes("utf8");
设置字符集为utf8
client.setStringSpace(string.getStringSpace());
将字符串转换为utf8格式
string.setFormatter(new Date().toUpperCase()); string.setBinary("utf8");
创建字符串缓冲区
chars = client.getString().toCharArray();
将字符串转换为UTF-8编码的字符串
byte[] bytes = bytearrays.toBytes(bytes);
解码
utf8buf = bytearrays.toBufferedWord(bytes, "UTF-8"); charsbuf = client.getString().toCharArray();
输出字符串
for (char c : string) { printf("%s ", c); } ```







