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

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

问题描述

使用此代码我将数据保存到 GAE 商店但是当存储阿拉伯语时,它在 Store 中的格式变为 ?????

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

如何在 GAE 中支持持久化阿拉伯文本?

how to support persist Arabic Text in GAE ?

代码:

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

推荐答案

当您从表单提交文本或将其呈现为 HTML 时,而不是在存储(或检索)时,文本更有可能损坏.

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();

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

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());

记录(或显示)ok 的值.如果false,那么真的是持久层无法处理阿拉伯语.发布您的发现,一旦我们对问题的真正所在更有信心,我们就会努力寻找解决方案.

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.

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

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天全站免登陆