在java中打印阿拉伯字符串 [英] Print arabic string in java

查看:103
本文介绍了在java中打印阿拉伯字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在java中显示阿拉伯语文本,但它显示垃圾字符(例如:¤[ï߯[î]或有时仅打印时出现问号)。我怎么做它打印阿拉伯语。我听说它与unicode和UTF-8有关。这是我第一次使用语言,所以不知道。我正在使用Eclipse Indigo IDE。



编辑:
如果我使用UTF-8编码,那么¤[ï߯[î字符正在变成? ???????你可以看一下here 。这应该允许你在其控制台中创建Eclipse打印unicode(我不知道它是否是Eclipse支持开箱即用而没有任何额外的调整)



如果这不能解决您的问题,您很可能遇到程序使用的编码问题,因此您可能希望以某种方式创建字符串:



String str = new String(تعطييونيكودرقمافريدالكلحرف。getBytes(),UTF-8);



这至少对我有用。


I'm trying to display arabic text in java but it shows junk characters(Example : ¤[ï߯[î) or sometimes only question marks when i print. How do i make it to print arabic. I heard that its something related to unicode and UTF-8. This is the first time i'm working with languages so no idea. I'm using Eclipse Indigo IDE.

EDIT: If i use UTF-8 encoding then "¤[ï߯[î" characters are becoming "????????" characters.

解决方案

For starters you could take a look here. This should allow you to make Eclipse print unicode in its console (which I do not know if it is something which Eclipse supports out of the box without any extra tweaks)

If that does not solve your problem you most likely have an issue with the encoding your program is using, so you might want to create strings in some manner similar to this:

String str = new String("تعطي يونيكود رقما فريدا لكل حرف".getBytes(), "UTF-8");

This at least works for me.

这篇关于在java中打印阿拉伯字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆