请教从数据库里查询出来的字符的字节数,谢谢

oracleperl oracleperl 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
drop table test;
create table test
(
name varchar(1)
) engine=myisam default charset=utf8mb4;

insert into test values('严');
commit;

然后执行如下SQL,发现“严”占了3个字节
mysql> select name,length(name) from test;
+------+--------------+
| name | length(name) |
+------+--------------+
| 严 | 3 |
+------+--------------+

这说明这个汉字保存成了UTF-8编码

现在我
static HashMap<String,String> h_test = new HashMap<String,String>();
String str=rs.getString("name");
h_test.put(str,"");
请问str里和h_test里的“严”是UTF-8编码的码?

如何知道str的字节数?

谢谢
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
oracleperl
Java SE 62,620 成员 307,251 内容