From ea4b642874cbb94587906f36f5a2230df23f7ede Mon Sep 17 00:00:00 2001 From: "Brian P. Hinz" Date: Mon, 2 Mar 2015 20:03:42 -0500 Subject: [PATCH] Decode serverCutText to ISO-8859-1 Java viewer was incorrectly attempting to decode incoming clipboard updates to UTF-8 instead of Latin-1. --- java/com/tigervnc/rfb/CMsgReader.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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() -- 2.39.5