1

I have configured Kannel to send messages to my servlet. The URL is like this:

http://10.10.10.10/income/Submit?from=%p&to=%P&content=%a&encoding=%C

The problem is encoding is UTF-8 for English messages and UTF-16BE for Persian messages. My servlet is like:

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");

    String to = request.getParameter("to");
    String from = request.getParameter("from");
    String content = request.getParameter("content");

    /* process message here */
}

With this code I can not get Persian messages.(They are converted to ASCII). When I convert request.setCharacterEncoding("UTF-8"); to request.setCharacterEncoding("UTF-16BE");, I get null for all variables. Can anyone help me how can I convert to, from, content based on encoding field? I'm using Glassfish 3.1.2.2 as container.

2
  • In fact, you have to ensure that UTF-8 exists in THREE places! Make sure that all of them are there. Here is a good explanation how: stackoverflow.com/a/10971742/2542027 Commented Aug 5, 2013 at 10:11
  • On Glassfish, request.setCharacterEncoding() has totally no effect on GET query strings. It only affects the POST request body. As far as I know JBoss AS >=7 is the only server which allows you to configure via its standalone.xml to use the same POST request body encoding for decoding of GET query string. But on all others you've to explicitly configure it separately. Therefore, your question wherein you're implying that altering the POST request body encoding has effect on GET query string decoding, is somewhat suspicious. Did you really made the right observations? Commented Aug 5, 2013 at 19:43

1 Answer 1

1

In Kannel you can set mo-recode to 1 in smsbox group. This will tell Kannel to automatically transcode text MO messages to UTF-8 charset before sending to your HTTP service.

Just ensure if your Kannel is built with iconv support.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.