开发者

GAE Arabic Support

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

how to support persist Arabic Te开发者_StackOverflow社区xt 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜