2 Replies Latest reply on Oct 26, 2006 10:09 AM by 807607

    Encoding??? Weird characters (char)65533


      I have been giving the pleasant task of bugfixing something that is not created by me. I've been trying to fix it, but I don't seem to get the solution.

      The problem is that users are allowed to enter data on a php website. The data is then stored in a MySQL database BLOB field. A java application gets the data from the database and makes a PDF from that.

      The problem is that when the Java program fetches the String from the ResultSet, all characters like "�,�,�" have been replaced by a '?'. The (char)65533. I have a feeling this has something to do with encoding???

      I have actually no clue what to do... Can somebody enlighten me on this problem?
        • 1. Re: Encoding??? Weird characters (char)65533
          This is definately an encoding problem.
          It is because of the BLOB type for your column, this is for binary data and has no character set. Try to change the column type to TEXT instead. MySql supports the utf-8 character set, so special characters shouldn't be a problem.
          • 2. Re: Encoding??? Weird characters (char)65533
            Thanks for your response!

            This has worked! I now get the right characters. I have made a function which fixes the strings fetched from the database to the ISO-8859-1 encoding.
            The problem is that not everybody entered the data in this encoding. It seems some users also used the UTF8 encoding. Is there a way to determine the encoding of a string? People can choose what encoding to use in their browser...
            private String fixstring() throws UnsupportedEncodingException {
            byte[] byte_array = s.getBytes("ISO-8859-1");
            return new String(byte_array, "ISO-8859-1");
            Message was edited by: