GAE Arabic Support

廉价感情. 提交于 2019-12-11 10:44:30

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/6075995/gae-arabic-support

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!