You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Schumann Ye <Sc...@hotmail.com> on 2021/01/11 03:23:03 UTC

Encoding Issue

Dear Gurus,

I have the following scenario:

  1.  Displaying project gantt chart info with an Ofbiz app;
  2.  Users are allowed to change the gantt info as they wish;
  3.  Users can then save the project gantt info into a json dataset that is stored at client side;
  4.  Once clicking "save" button to save the modified project info into Server (the json file would be then stored in hard disk of the server. It could be also uploaded into the server database.);
It is done via ofbiz controller.xml with proper mapping and codes (here I wrote some java code) as below:

public static String exportProject(HttpServletRequest request, HttpServletResponse response) {
        try {
            request.setCharacterEncoding("UTF-8");
            response.setCharacterEncoding("UTF-8");
        } catch (Exception e) {
            e.printStackTrace();
        }
        Delegator delegator = (Delegator) request.getAttribute("delegator");
        LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
......

Everything runs as I expected except the encoding was failing to encode "Chinese" character when I checked the exported file (instead of showing "???").

I am pretty sure the coding & schema that I used is ok because I had used it in other "NON" ofbiz environment.
So I checked and found there was similar question like OFBIZ-5929.

Can anyone guide me how to solve the issue?
Thanks

Schumann