Reputation: 392
I'm trying to transfer a file from my Java Servlet to a small HTML Web implementation.
I'm using a regular http ajax request to the servlet and the problem is that every byte sent from the Servlet that is outside the 0-127 range is being read on Javascript as 65533, thus creating bad files on the receiving end.
I've been doing the Ajax request on XHR, Jquery and AngularJS and got the same result every time.
Why is this happening ? What can I do to fix this ?
Upvotes: 0
Views: 1155
Reputation: 1
���N�ne�]_�'ǭT��n��>�q���Z�L�L2��By�z���4$����X�}�]ũ�<���
�~ϵW��5<�?}�Å🨅o�t�����b�oD2ɖ�7Lq!���In��
�58�>N�?�#����l����HA��d�A�J&RF�q���]*T]�P�u�F��ud'9���א�V��D�����5C�����̞�<�aIz6܍X�p�P����d���O��F�R�ZXXX�Wi|��������Q)ew��8��:5�������
�������yII����zz��:V/�eP�7�IU�=���?J['������b!Gi�ba�Q^�!Gz����At�Le����x�X�e¨�o�!^�����eG�%�O
o���$6��*�ײ�������1�������ܔ�V@kD�ʯH����E�� gԑ���QK7|�O3w*�0卖�!t'����&�/��[�u�Y�6���_�<�ݒ"m��?{�8�_���6{�%��&Dݓ������l�sb
���¢d],���k��?ؿ���z8�����0�k������Xi��:)�i�v�UׅY�h��>f���?�;�Z���NPE�g�T�
��>��jSl���S�]TpP�G=L0�V�/��Of��L�γ"��m�/��I���-|X4J����G*���3�<Ա�Ya���;�1�`;r�[���[co��u�˾HK�r���<���X)��+c���@�IX �;$<�dD�9�
256
Upvotes: -1
Reputation: 21
Your input stream is being read as UTF-8, so replace it with ISO-8859-1
UTF-8 is a multibyte encoding that can represent any character.
ISO 8859-1 is a single-byte encoding that can represent the first 256 Unicode characters.
UTF-8 replaces certain characters outside a range with special 'Unicode replacement character' which in your case is 0xFFFD (65533 in Hex).
Upvotes: 2