GAE阿拉伯语支持 [英] GAE Arabic Support

查看:123
本文介绍了GAE阿拉伯语支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用这段代码我坚持数据到GAE商店
,但是当存储阿拉伯语时,它的格式在商店成为?????



如何支持坚持阿拉伯语在GAE中的文本?



代码:

  PersistenceManager manager = PMF 。获得()getPersistenceManager(); 
Category category = new Category(categoryName);
manager.makePersistent(category);
manager.refresh(category);
manager.close();


解决方案

它可以从表单或呈现给HTML,而不是存储(或检索)。



作为一个快速测试,试试这个:

  String test =\\\ا\\\ل\\\س\\\ل\\\ا\\\م; 
PersistenceManager管理器= PMF.get()。getPersistenceManager();
Category category = new Category(test);
manager.makePersistent(category);
manager.refresh(category);
manager.close();

如果显示正确(السلام),那么问题在于输入在应用程序中的处理方式。如果它仍然出现损坏,请尝试另一个检索类别名称的测试,并在您的应用程序中将其与 test 的原始值进行比较。测试可能如下所示:

 布尔值okay =\\\ا\\\ل\\\س\\\ل\ u0627\\\م\" .equals(category.getName()); 

记录(或显示)的值。如果 false ,那么它确实是无法处理阿拉伯语的持久层。发布您的调查结果,一旦我们更确信问题出在哪里,我们将努力寻找解决方案。




更新:如果通过 setHeader()设置,servlet引擎不能保证识别出字符编码。使用 setContentType() 方法或 setCharacterEncoding() 方法。


using this code i persist data to GAE Store but when storing Arabic it's format in Store become ?????

how to support persist Arabic Text in GAE ?

the code :

    PersistenceManager manager = PMF.get().getPersistenceManager();
    Category category = new Category(categoryName);
    manager.makePersistent(category);
    manager.refresh(category);
    manager.close();

解决方案

It's more likely that the text is corrupted when you submit it from a form, or render it to HTML, rather than when it is stored (or retrieved).

As a quick test, try this:

String test = "\u0627\u0644\u0633\u0644\u0627\u0645";
PersistenceManager manager = PMF.get().getPersistenceManager();
Category category = new Category(test);
manager.makePersistent(category);
manager.refresh(category);
manager.close();

If that displays correctly (السلام), then the problem is with the way the input is handled on its way into the application. If it still appears corrupted, try another test where you retrieve the category name, and within your application, compare it to the original value of test. The test might look something like this:

boolean okay = "\u0627\u0644\u0633\u0644\u0627\u0645".equals(category.getName());

Log (or display) the value of okay. If false, then it really is the persistence layer that can't handle Arabic. Post your findings, and we'll work toward a solution once we are more confident where the problem truly is.


Update: The servlet engine is not guaranteed to recognized the character encoding if you set it via setHeader(). Use the setContentType() method or the setCharacterEncoding() method instead.

这篇关于GAE阿拉伯语支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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