1Password / arboard

A clipboard for Rust
Apache License 2.0
640 stars 73 forks source link

Incorrect .get_text() decoding #152

Open KamWithK opened 5 months ago

KamWithK commented 5 months ago

Sometimes with some applications they'll put text into the clipboard which arboard's .get_text() returns incorrectly or fails on. Most of the time managing to decode most of the text but then appending extra characters at the end of the line, but sometimes also returning an error as the result.

For example I have a game which copies this onto the clipboard: image

Every clipboard reader program I have tried correctly outputs: 偽の花嫁に扮し、駿府へ向かった旅から数日が過ぎた。

However for some reason arboard outputs: 偽の花嫁に扮し、駿府へ向かった旅から数日が過ぎた。タ䍴䎂܀翪룀ᤰ㧘ü

Here is the byte array: [227, 128, 128, 227, 128, 128, 229, 129, 189, 227, 129, 174, 232, 138, 177, 229, 171, 129, 227, 129, 171, 230, 137, 174, 227, 129, 151, 227, 128, 129, 233, 167, 191, 229, 186, 156, 227, 129, 184, 229, 144, 145, 227, 129, 139, 227, 129, 163, 227, 129, 159, 230, 151, 133, 227, 129, 139, 227, 130, 137, 230, 149, 176, 230, 151, 165, 227, 129, 140, 233, 129, 142, 227, 129, 142, 227, 129, 159, 227, 128, 130, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 239, 190, 128, 228, 141, 180, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 194, 128, 0, 0, 0, 1, 0, 238, 141, 160, 228, 142, 130, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 220, 128, 231, 191, 170, 127, 235, 163, 128, 225, 164, 176, 227, 167, 152, 195, 188, 0, 0, 0, 0, 0]

I use println!("{}", &text) to check the printed text and println!("{:?}", &text.as_bytes()) to check the bytes. This happens with every single line in this game 剣が君 百夜綴り (ken ga kimi momoyo tsuzuri) when on Windows 11 (haven't tried any other OS/version). So I assume it's a problem in decoding the text?

I downloaded a program Free Clipboard Viewer to try and debug further and under the "Unicode Text Format" right hand side it shows the same thing as arboard outputs but under the preview tab it correctly prints the line. Export of one line which exhibits the problem.

Copy pasting only the part arboaord got correct won't result in arboard reproducing the error so I'm not sure what more can help reproduce the error.