1 Reply Latest reply on Apr 14, 2005 4:30 PM by jason.greene

    Howto transform a byte array of unknown encoding to a string

    thomas.diesler

      A WS request/response message maybe of UTF-16 or use a Byte Order Marker (BOM) with UTF-8

      In the Axis code I found places where they do

      new String(byteArray, "UTF-8")
      


      ignoring the possibility that byteArray may be encoded differently.

      If the WS input stream is passed directly to the DeserializationContextImpl all works fine. If the same input stream is first transformed into a String, as it is the case when logging is enabled, deserialization fails with

      org.xml.sax.SAXParseException: Content is not allowed in prolog.
      


      There are a number of CTS tests that reliably fail when logging is enabled.

      How do I transform a byte array of unknown encoding to a String?