macOS regression: Drag and Drop seems to drop UTF-16 instead of UTF-8
Bug description:
In wxWidgets v3.3.3.1, Drag and Drop seems to be dropping plain text as UTF-16LE when UTF-8 would be appropriate. I could not reproduce this issue with v3.2.11.
Expected vs observed behaviour:
Use the dnd.app sample program and a suitable program to receive the drop, I suggest the terminal.app. Note that iTerm2 and some text editors will accept UTF-16 input and thereby mask the problem. Use the "File->Test Drag..." menu item to enter some test text, then drag it to the target window. Notice that the pasted text has a nul character after each character of the text. This does not happen with v3.2.11, the drop only pastes the plan text as expected. Normal copy/paste does not seem to be affected.
Patch or snippet allowing to reproduce the problem:
The standard dnd sample app is sufficient without modification.
To Reproduce:
- Launch the dnd sample and the terminal app.
- Use the "File->Test Drag..." menu item to enter some test text
- Drag from the dnd window to the terminal window
- Observe that UTF-16LE text is pasted into the terminal. This is the result of dragging the default text to the terminal prompt:
w^@x^@W^@i^@d^@g^@e^@t^@s^@ ^@d^@r^@a^@g^@ ^@&^@ ^@d^@r^@o^@p^@ ^@w^@o^@r^@k^@s^@ ^@:^@-^@)^@As a comparison 3.2.11 drops the text as:wxWidgets drag & drop works :-)
As an alternate test: Enter a URL as the test text and drag to the Safari URL bar, the text will be pasted thus:
w%00x%00w%00i%00d%00g%00e%00t%00s%00.%00o%00r%00g%00
Platform and version information
- wxWidgets version you use: 3.3.3.1
- wxWidgets port you use: wxOSX
- OS and its version: macOS 15.7.9 on M1Max
Source: wxWidgets/wxWidgets