小程序中日文字体出现乱码
我有一个 Java Swing 应用程序 JAR 作为 JSP 中的小程序运行。 在其中一个 JTextfield 中,用户粘贴日语字符,结果显示为乱码。 但是,当我将同一个应用程序作为小程序运行时,它显示得很好。 JSP 的内容按照 META 标记表示为 UTF-8。
I have a Java Swing application JAR running as an applet in a JSP. In one of the JTextfields, a user pastes Japanese language characters, and it shows up garbled. However, when I run the same application as an applet, it shows up just fine. The JSP has the content represented as UTF-8 as per the META tag.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我猜有几种可能。 当显示器认为它是有效字符,但无法找到与该字符对应的字形(字体中的条目)时,可能会显示框。
您是否可能没有安装包含这些字符的字体? 或者甚至小程序无法将这些代码点映射到系统中的某种字体?
如果问题是由于预期字符编码和实际字符编码之间不匹配造成的,我认为它不仅仅是盒子,而且还可能包含不正确的字符,即 gobbledy-gook。
There are a few possibilities I guess. Boxes may be shown when the display thinks that it is a valid character, but it is unable to find a glyph (entry in the font) corresponding to that character.
Is it possible that you don't have a font installed which contains those characters? Or even that the applet is unable to map these code points to a certain font in your system?
If the problem were due to a mismatch between expected and actual character encoding, I think it would not just be boxes, but it would also probably contain incorrect characters, ie gobbledy-gook.
我对日语本地化问题有一些经验,所以我会尝试提供一个可能的解决方案(尽管很晚了)。
JSP内容编码与applet使用的编码无关。 小程序正在使用用户默认用户 JRE/JVM 设置。
假设日语至少在一个屏幕上向用户显示,这是复制和粘贴管理器不知道如何复制文本的问题(它复制文本的字节,但在粘贴时错误地重新组装字节) ):
向应用程序添加诊断屏幕,并在您的计算机和用户计算机上记录以下系统属性:
小程序启动后,您应该能够使用您的计算机覆盖这些属性。拥有正确的设置,以便在所有用户电脑上获得正确的行为。
I've had a little experience with Japanese localisation issues so I'll try to offer a possible solution (although quite late).
The JSP content encoding has nothing to do with the encoding used by the applet. The applet is using the user default user JRE/JVM settings.
Assuming that the Japanese appears to the user on at least one screen, this is an issue with the copy and paste manager not knowing how to copy the text (its copying the bytes of the text but then when pasting its re-assembling the bytes incorrectly):
Add a diagnostic screen to the app and log the following system properties on your computer and the user computer:
Upon start-up of the applet, you should be able to override the properties with your own correct settings to get the correct behavior on all user PCs.