convert tabs to spaces when getting clipboard text

this avoids tab characters being translated to "?" when converted to
cp437
develop
Myk Taylor 2023-07-21 15:03:06 -07:00
parent ac8211a9c7
commit 77d0fb297c
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
1 changed files with 5 additions and 0 deletions

@ -151,6 +151,11 @@ DFHACK_EXPORT std::string DFHack::getClipboardTextCp437() {
if (!g_sdl_handle || g_SDL_HasClipboardText() != SDL_TRUE)
return "";
char *text = g_SDL_GetClipboardText();
// convert tabs to spaces so they don't get converted to '?'
for (char *c = text; *c; ++c) {
if (*c == '\t')
*c = ' ';
}
std::string textcp437 = UTF2DF(text);
DFHack::DFSDL::DFSDL_free(text);
return textcp437;