通过DB2 Control Center直接向表中输入汉字
如果这个问题听起来微不足道,请原谅我,我之前没有任何使用 Unicode 编码/解码的经验。
我有一个已经完成的 Java Web 应用程序。它有一些网页表单让用户输入数据并将其保存到数据库中。目前对大多数数据都可以正常输入,但无法正确输入汉字。
我想做的是找出问题出在哪里。我从 DB2 开始,尝试将从中文网站复制的 UTF-8 编码的汉字粘贴到使用 Control Center 的表中。它变成一系列垂直条,看起来像粗体 Arial 字体的 L 字符。我正在使用适用于 Windows 的 DB2 版本 9 UDB。
我的问题是:我是否需要为 DB2 启用 Unicode 支持以及如何做到这一点?使用 JDBC 保存数据时是否需要指定字符集为 UTF-8?如何实现?
多谢。
Pardon me if this question sounds trivial, I don't have any experience working with Unicode encoding/decoding before.
I have a Java web application that is already complete. It has some web forms to let the user input data and save them to the database. Currently it works well for most kinds of data, but failed to input Chinese characters correctly.
What I am trying to to is to figure out where things go wrong. I started with DB2, trying to paste a Chinese character that I copied from a Chinese website, which was UTF-8 encoded, to a table using Control Center. It turns to a sequence of vertical bars, which look like the L character in bold Arial font. I'm using DB2 ver 9 UDB for Windows.
My question is: Do I need to enable Unicode support for DB2 and how to do that? Do I need to specify the charset as UTF-8 when using JDBC to save the data, and how this can be done?
Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以按照 IBM 的说明进行操作:
https://www-304.ibm .com/support/docview.wss?uid=swg21200211
图 1:从 DB2 控制中心打开表对话框,在英语环境中显示方框而不是繁体中文字符。
要使用已安装的 Unicode 字体,必须相应更新 font.properties 文件。
例如,安装TwinBridege繁体中文明字体(TSC FMing S TT)来显示繁体中文字符。字体名称可以在 XP 上的 C:\Windows\Fonts 或 Windows 2000 上的 C:\WINNT\Fonts 中找到:
要使用该字体,请在“sansserif.”和“dialog.”中进行映射。部分必须包含字体名称“TSC FMing S TT”。按如下所示更新 font.properties:
示例:
添加以下行以映射“dialog”以使用 TSC FMing S TT 字体。
安装字体并在 font.properties 中映射字体后,可以在 Control Center 中以英语呈现 Unicode 数据...
图 3:从 DB2 Control Center 中打开表对话框,设置后在英语环境中显示繁体中文字符。
You can follow the instructions from IBM:
https://www-304.ibm.com/support/docview.wss?uid=swg21200211
Figure 1: Open Table dialog from DB2 Control Center, showing boxes instead of Traditional Chinese characters in an English environment.
To use a Unicode font installed, the font.properties file has to be updated accordingly.
For instance, TwinBridege Traditional Chinese Ming Font (TSC FMing S TT) is installed to display Traditional Chinese characters. The font name can be found in C:\Windows\Fonts on XP or C:\WINNT\Fonts on Windows 2000:
To use the font, the mapping in 'sansserif.' and 'dialog.' section has to include the font name 'TSC FMing S TT'. Update the font.properties as follows:
Example:
Add the following line to map 'dialog' to use TSC FMing S TT font.
With the font installed, and font mapped in font.properties, the Unicode data can be rendered in the Control Center in English...
Figure 3: Open Table dialog from DB2 Control Center, showing Traditional Chinese characters in an English environment after the setup.