From: Brian P. Hinz Date: Tue, 3 Mar 2015 01:03:42 +0000 (-0500) Subject: Decode serverCutText to ISO-8859-1 X-Git-Tag: v1.4.90~34 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ea4b642874cbb94587906f36f5a2230df23f7ede;p=tigervnc.git Decode serverCutText to ISO-8859-1 Java viewer was incorrectly attempting to decode incoming clipboard updates to UTF-8 instead of Latin-1. --- diff --git a/java/com/tigervnc/rfb/CMsgReader.java b/java/com/tigervnc/rfb/CMsgReader.java index 71045f38..a93324ca 100644 --- a/java/com/tigervnc/rfb/CMsgReader.java +++ b/java/com/tigervnc/rfb/CMsgReader.java @@ -23,6 +23,9 @@ package com.tigervnc.rfb; +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.charset.Charset; import com.tigervnc.rdr.*; abstract public class CMsgReader { @@ -64,13 +67,9 @@ abstract public class CMsgReader { } byte[] buf = new byte[len]; is.readBytes(buf, 0, len); - String str = new String(); - try { - str = new String(buf,"UTF8"); - } catch(java.io.UnsupportedEncodingException e) { - e.printStackTrace(); - } - handler.serverCutText(str, len); + Charset latin1 = Charset.forName("ISO-8859-1"); + CharBuffer chars = latin1.decode(ByteBuffer.wrap(buf)); + handler.serverCutText(chars.toString(), len); } protected void readFramebufferUpdateStart()