I’m having an issue with SDL_GetClipboardText. First of all I am using delphi and since the bindings did not have SDL_Set/GetClipboardText translated, I did that myself by analogy, despite it being simple here’s how it looks:

function SDL_SetClipboardText(const text: PChar): Integer;
cdecl; external SDL_LibName {$IFDEF MACOS} {$IFNDEF IOS} name ‘_SDL_SetClipboardText’ {$ENDIF} {$ENDIF};

function SDL_GetClipboardText: PChar;
cdecl; external SDL_LibName {$IFDEF MACOS} {$IFNDEF IOS} name ‘_SDL_GetClipboardText’ {$ENDIF} {$ENDIF};

SDL_SetClipboardText actually works fine and I can copy text out of the program and paste it anywhere, except back to the program. There are two cases, one when it works - single character pasting (from anywhere to the program), and >1 character pasting which just returns gibberish (regardless from where I copy). Further poking around revealed that the gibberish text is not my fault as a result of converting from one string type to another, the function already returns gibberish.

And that’s why I am quite confused. Could someone provide any insight as to why this is happening? Or how to fix it?