On 08.02.2016 20:27, Jason Ricles wrote:
The message is built and sent in a javaclass connected to a websocket
server for the web application also written in java then the message
is passed to the webpage which uses javascript

1) on this list, do not "top post". See :
http://tomcat.apache.org/lists.html#tomcat-users  #6

2) this is now very confusing. Are you talking about data flowing from the server to a bowser client, or from a browser client to the server, or both, and in what order ?
(maybe a little ASCII-graphic schema would help)

Anyway, if you are sending/receiving text data "disguised" as binary data, then you are responsible for making sure that both ends know which character set/encoding is being used, and *program* the proper encoding/decoding at both ends.

What you are seeing in the buffer right now is not junk. It is exactly what was written by the side doing the writing. The problem is that the side doing the reading, does not know how this data is encoded, so it does not "understand" it properly.

For a websocket, there is no Tomcat setting (that I know of) that will change that. You will have to do this in your applications (on both server and client sides).

And if you instead want to exchange text data, then as far as I know (per RFC 6455) it MUST be encoded as UTF-8.
See https://tools.ietf.org/html/rfc6455#section-5.6


On Mon, Feb 8, 2016 at 2:25 PM, André Warnier (tomcat) <a...@ice-sa.com> wrote:
On 08.02.2016 19:41, Jason Ricles wrote:

I have an application that sends binary websocket messages between a
class and the web application using a websocket server written in
java.

The data being sent from the java class is encoded in a binary buffer
with the bytes in ISO8859_1. However, when I receive the bytes on the
websocket server and the web application end they are junk (such as
-121, -116, etc.) and not encoded the correct way that they need to
be.

I was reading that this might be caused by something being set in my
websocket server and web application to use UTF-8 for the default and
not ISO8859_1.

Is there any way I can change my websocket server and my web
application which uses JavaScript to use ISO8859_1 instead of UTF-8?


Now is it Java, or JavaScript ? (earlier you say "sent from the java
class"..)



For a proper "correct" solution, the client sending text data to the server
should tell the server what character set/encoding is used for that data
(via some kind of "header" for example).  This way, the server could always
read that text data and decode it in the proper way.

If you are /sure/ that this server socket, now and in the future, will only
ever receive text data from this particular version of your client
java/javascript code, and that text will always be encoded as iso-8859-1,
then you should at least make sure that the server code which is reading and
decoding this data, does it as iso-8859-1, which is not the default
character set for java.
But by doing so, you are only moving the problem further in the future,
because as far as it looks right now, the usage of Unicode/UTF-8 will
increase, and the usage of iso-8859-x character sets will decrease over
time.




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to