Cactus
  1. Cactus
  2. CACTUS-29

The redirector can not send the double byte characters

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3
    • Fix Version/s: 1.5-beta1
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      Operating System: Windows NT/2K
      Platform: PC

      Description

      Could you please use same encoding to get result from the server through servlet
      output stream? When I run the following test case with Cactus, the international
      characters are corrupted to '?'. Since, the server side is using 'ISO-8859-1'
      encoding to send the result and the client side is using platform default
      encoding to get the result from server, then the ISO-8859-1 encoding can not
      send the double byte characters without corruption.

      Steps to Reproduce:
      Run the following test case with Cactus.
      Actual Results:
      > junit.framework.ComparisonFailure: expected:<aaa> but was:<???>
      Expected Results:
      > The '???' part shows 3 different double byte characters.

      package report;

      import javax.servlet.ServletException;

      import org.apache.cactus.ServletTestCase;

      public class TestServlet2 extends ServletTestCase {
      public TestServlet2(String name)

      { super (name); }

      public void testDoGet() throws ServletException

      { String hiragana1 = "\u305d"; // Hiragana So String katakana1 = "\u30bd"; // Katakana So String cjk1 = "\u8868"; // Kanji Hyou String actualTest = hiragana1 + katakana1 + cjk1; assertEquals("aaa", actualTest); }

      }

        Activity

        Hide
        Vincent Massol added a comment -

        Hi,

        Thanks for you bug report. I need to understand a few things as I am quite
        novice on this subject of i8n. You say "Could you please use same encoding to
        get result from the server through servlet output stream?". Do you mean that
        Cactus should :

        • on the client side: provide an API to set the character encoding to use so
          that the HTTP request sent is encoded using this encoding (specifying the
          encoding in the HTTP content-type head)?
        • on the server side, use ServletRequest.setCharacterEncoding() before reading
          from the request?
        • what about locales? Is it related?

        What would be great is if you could provide a patch against the Cactus code to
        implement what you have in mind. I will then commit it.

        Note: BTW, I don't how the example you have provided can show anything as it
        doesn't call anything from the container?

        thanks
        -Vincent

        Show
        Vincent Massol added a comment - Hi, Thanks for you bug report. I need to understand a few things as I am quite novice on this subject of i8n. You say "Could you please use same encoding to get result from the server through servlet output stream?". Do you mean that Cactus should : on the client side: provide an API to set the character encoding to use so that the HTTP request sent is encoded using this encoding (specifying the encoding in the HTTP content-type head)? on the server side, use ServletRequest.setCharacterEncoding() before reading from the request? what about locales? Is it related? What would be great is if you could provide a patch against the Cactus code to implement what you have in mind. I will then commit it. Note: BTW, I don't how the example you have provided can show anything as it doesn't call anything from the container? thanks -Vincent
        Hide
        ahasegawa added a comment -

        Hi Vincent,
        I create the patches that change the encoding to UTF-8 from ISO-8859-1
        in the http connection to transfer the test result, so the patches
        include both the client side and the server side.

        The locale is not related in this issue.
        Thanks,
        – Atsushi

        Show
        ahasegawa added a comment - Hi Vincent, I create the patches that change the encoding to UTF-8 from ISO-8859-1 in the http connection to transfer the test result, so the patches include both the client side and the server side. The locale is not related in this issue. Thanks, – Atsushi
        Hide
        Vincent Massol added a comment -

        Hi Atsushi,

        Thanks! I've started applying your patches. I have some questions/remarks:

        • On the server side, you have added the following line:

        webImplicitObjects.getHttpServletResponse().setContentType("text/html;
        charset=UTF-8");

        I have modified this to be located in AbstractWebTestCaller.doGetResults() and
        I have changed "text/html" to "text/xml" as it is XML that is returned. I hope
        this is fine with you.

        • Is UTF-8 going to work for everyone? I mean, do you know of any situation
          where it will break any existing code?
        • I have refactored the IoUtil.getText() methods so that they share more code.

        I do not have CVS access right now so I'll commit all this either tonight or
        tomorrow.

        Thanks
        -Vincent

        Show
        Vincent Massol added a comment - Hi Atsushi, Thanks! I've started applying your patches. I have some questions/remarks: On the server side, you have added the following line: webImplicitObjects.getHttpServletResponse().setContentType("text/html; charset=UTF-8"); I have modified this to be located in AbstractWebTestCaller.doGetResults() and I have changed "text/html" to "text/xml" as it is XML that is returned. I hope this is fine with you. Is UTF-8 going to work for everyone? I mean, do you know of any situation where it will break any existing code? I have refactored the IoUtil.getText() methods so that they share more code. I do not have CVS access right now so I'll commit all this either tonight or tomorrow. Thanks -Vincent

          People

          • Assignee:
            Vincent Massol
            Reporter:
            ahasegawa
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development