[HXCPP] Clipboard UNICODE support

Hello,
Does anybody know how are strings encoded when targeting HXCPP? Especially HxString in CFFIPrime.h. Currently, when you assign a string containing non-ASCII characters to Clipboard.text and then paste it to another application you get some garbage output. I was able to fix it by treating HxString as a UTF-16 encoded wide string and converting it to UTF-8 byte string before passing to Clipboard::SetText(). But I’m not sure if this would work or is even necessary on all platforms since so far I’ve only tested it on Windows. If anybody could help me with this, I would be really grateful.

I haven’t tried UNICODE but maybe it’s possible with my library native-clipboard:
Clipboard.set_data("CF_UNICODETEXT", myString);
Or maybe use set_bytes. I’ll try when I have time.
Anyway, in windows clipboard, unicode string are usually inside CF_UNICODETEXT which is not use by Lime/SDL. But I don’t know for other platforms. I plan to add linux and mac but there is not ETA.

Thanks for your reply. My goal is to fix it in Lime and I was successful in that regard but I’m not sure if that’s the right way to do it. I suppose I’ll just try on Linux in a virtual machine and see how it works and then send a PR to Lime maintainers.

My fix looks like this:

void lime_clipboard_set_text (HxString text) {
	std::wstring str(reinterpret_cast<const wchar_t *>(text.c_str()));
	std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> convert;
	Clipboard::SetText (convert.to_bytes(str).c_str());
}