ResultSet的Unicode字符的getString字符编码 [英] ResultSet getString character encoding for unicode characters
问题描述
在我的swing应用程序中,我将显示数据库中的印地文unicode字符. 当我显示名称时,它按原样显示,而不是印地文字符串.
In my swing application I am going to display hindi unicode charecters from the database. When I am displaying name, it showing as it is, not as a hindi string.
但是当我将其硬编码到程序中时,它可以正确显示.问题是什么.从数据库获取数据时,是否有任何charecter编码选项.我在Netbeans中使用oracle xe.
But when I hardcoded it into the program it is showing correctly. What is the problem. Is there any charecter encoding option while getting the data from database. I am using oracle xe with Netbeans.
String name = rs.getString("name");
jLabel1.setText(name);
此处按原样显示unicode字符. 但是这里
Here it displaying unicode charecters as it is. But here
String name = "\u0938\u093e\u092e\u093e\u0928\u094d\u092f";
jLabel1.setText(name);
显示正确.问题出在哪里.
It showing correctly. Where is the problem.
推荐答案
问题出在Oracle使用的编码中.您还必须将其设置为在数据库中也使用UTF-8.不幸的是,您无法在JDBC类中解决此问题.
The issue lies in the encoding that Oracle is using. You have to set it up to use UTF-8 in the database as well. Unfortunately, you can't fix this in the JDBC classes.
这篇关于ResultSet的Unicode字符的getString字符编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!