ultravnc / UltraVNC

UltraVNC Server, UltraVNC Viewer, UltraVNC Repeater and UltraVNC SC | Official repository: https://github.com/ultravnc/UltraVNC
https://uvnc.com
GNU General Public License v3.0
866 stars 196 forks source link

Multi byte character copy/paste issue #72

Open KazukiOhno opened 1 year ago

KazukiOhno commented 1 year ago

Thank you for very nice program with open source. I use UltraVNC on Windows11 and connect to Raspberry Pi. But I have a trouble when I select Japanese character, I can't find '?' instead of Japanese character. On the other hand, current program is no problem when I copy/paste 1 byte character like ASCII.

I'm looking for how to fix multi byte character copy from Raspberry Pi to Windows. I suppose ReadServerCutText in ClientConnection.cpp can handle only 1 byte character. Perhaps ReadString() function in this ReadServerCutText was made based on 1 byte charater text case only.

However I could not know how to get text from clipboard on this program. In UltraVNC, I can copy/paste including Japanese character correctly. So, if I could have multi byte character or Unicode in this program, I would translate shift JIS (Japanese standard character code on WIndows). Because when I put shift JIS code into m_netbuf in the function of ReadServerCutText(), I could paste test with Japanese character onto Windows. Thank you for your help or advise.

RudiDeVos commented 1 year ago

The Japanaese keyboard is working. You need to select it on the viewer. image

To fast, seems you are using a linux viewer Try server settings image

KazukiOhno commented 1 year ago

Thank you for your advice, but my point is different.

cap1 I'd like to ask as this picture. 日本 is Japan in chinese charcter on Raspberry Pi. And I select them and copy. Then go to Windows Memo pad and paste to it. Then I only get have ?? instead of 日本. When I try to fix this, I found UltraVNC handles multi byte character as byte. On Windows, Japanese character code is shift JIS=SJIS. 日本 case, 0x93FA, 0x967B.

On the other hand, I copy same word 日本 on Windows and paste to RPi on VNC. I could find below picture. cap2 On RPi, it uses UNICODE, I understand SJIS code just appears on the screen. Then I can see like 0x93 u (umlaut) and 0x96 { insted of 日本 word. If I can translate SJIS to Unicode, I might get correct Japanese.

If this explanation helps you to understand, I'm happy.

RudiDeVos commented 1 year ago

Clipboard format is CF_UNICODETEXT see Clipboard.cpp line 192

const UINT ClipboardSettings::formatUnicodeText =   CF_UNICODETEXT;
const UINT ClipboardSettings::formatRTF =           RegisterClipboardFormat("Rich Text Format");
const UINT ClipboardSettings::formatHTML =          RegisterClipboardFormat("HTML Format");
const UINT ClipboardSettings::formatDIB =           CF_DIBV5;

But this is the extendedClipboard, both viewer and server need to understand extendedClipboard protocol.

rfbproto.h ..

typedef struct {
    CARD8 type;         /* always rfbServerCutText */
    CARD8 pad1;
    CARD16 pad2;
    CARD32 length; // will be negative to notify viewer that it accepts extended clipboard data.
    // adzm - 2010-07 - Extended clipboard support
    /*
    rfbEncodingExtendedClipboard provides extended clipboard functionality.
    If extended clipboard data is being used, the length will be negative.
    The message follows with unsigned char[abs(length)] data. The first sz_rfbExtendedClipboardData is the rfbExtendedClipboardData struct.
    The server notifies the viewer that it accepts the rfbEncodingExtendedClipboard extension to the protocol
    by immediately sending an rfbServerCutTextMsg with the clipCaps flags set in rfbExtendedClipboardData,
    which determines current version and also size limits of the main clipboard formats.

    if using classic clipboard, followed by char text[length]
    */
} rfbServerCutTextMsg;
KazukiOhno commented 1 year ago

Thank you, RudiDeVos, I already checked rfbServerCutTextMsg structure but I didn't know Clipboard.cpp has UNICODE. Then I think this issue comes from Server side VNC. On my RaspberryPi uses RealVNC. This might not have a capability extended Clipboard or Multi Byte Char code. Much appreciate you to teach me kindly how to manage UNICODE on UltraVNC. I should close this topic.

KazukiOhno commented 1 year ago

I asked RealVNC, then I could find a solution. That is using RealVNC viewer on Windows. Now I have RealVNC on RaspberryPi with RealVNC server and RealVNC viewer on Windows, then my problem was resolved. There is no issue on copy/paste Japanese text (multi byte code) each other.

Neustradamus commented 1 year ago

@KazukiOhno: With UltraVNC Viewer, it does not work? Have you tested the 1.4.2.2-dev?

If it does not work, there is a problem to fix...

KazukiOhno commented 1 year ago

Thank you for informing me this version update.

I installed this version and checked whether previous matter is improved. Unfortunately, no change from previous version.

When I copy the text on UltraVNC including Japanese Kanji character and paste on Windows11 memopad, multi byte character replaces by '?'. This is same phenomena as previous version.

I just report to you. I appreciate you to continue to provide UltraVNC to all.

Thanks,

Kazuki Ohno

On 2023/05/15 7:47, Neustradamus wrote:

@KazukiOhno https://github.com/KazukiOhno: With UltraVNC Viewer, it does not work? Have you tested the 1.4.2.2-dev?

If it does not work, there is a problem to fix...

— Reply to this email directly, view it on GitHub https://github.com/ultravnc/UltraVNC/issues/72#issuecomment-1547018559, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK3MC27CDLZ7HYSYW4OGDATXGFOINANCNFSM6AAAAAAVAKA3OM. You are receiving this because you were mentioned.Message ID: @.***>

KazukiOhno commented 1 year ago

Thank you for asking. I installed new version 1.4.3.1 and tried to copy Japanese (multi byte character) and paste on Windows. Unfortunately, it does not work well as previous version. I don't want to reopen this topic. Because I could find RealVNC works well and move to RealVNC. I hope UltraVNC also could work multi byte character handling. I like UltaraVNC. Thank you!

RudiDeVos commented 1 year ago

unicode is handled in an extension in UltraVNC, this is only available for clients using this extension. When i alot of time i need to check if the default can be changed without breaking any backward compatibility with UltraVNC.

Neustradamus commented 3 months ago

@KazukiOhno: Can you try 1.5.0.3-dev? It is same?