<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Windows: File Selection and Clipboard broken after unicode change</title>
		<link>http://www.allegro.cc/forums/view/618026</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sun, 02 Feb 2020 14:00:53 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi all, I have recently updated my allegro from git to the current master branch. After that, I noticed that two things don&#39;t work (for me) as they did before: </p><p>1) copy to clipboard from my app only shows &quot;I&quot; after paste into an editor.</p><p>2) the file selection dialog, when called with a file filter, shows no files.</p><p>I looked back into the history and found that the last changes to win_dialog.c (bac7bddc9d79cf6d520f27335e01f78ddbb99d34) and wclip board.c (b2e6f42d9525b16553913a041063118d803ab3f5) broke it, so I copied those files back from the version before and things works fine again (for me).</p><p>Not sure what it is. I&#39;m using MSVC 2017, platform toolset is &quot;Visual Studio 2017 (v141)&quot; and WIndows SDK is &quot;10.0.17763.0&quot;. So I&#39;m not aware that this is so much out of date, and I see that I&#39;m also using MBCS instead of Unicode, but I would expect that the allegro code adapts to that setting in a more graceful way. Or would I need to switch to Unicode here? Hm.</p><p>I guess that this question goes mostly to Peter Hull, he did the changes some months ago.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tobing)</author>
		<pubDate>Sat, 18 Jan 2020 15:02:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Interesting! Can you clarify what you are doing? Are you passing non-UTF8 strings to Allegro? I think the idea of those changes was that they were mostly internal, Allegro always expects UTF8 coming in, and internally converts it to a 16 bit encoding that Windows wants. It shouldn&#39;t matter what the host program is compiled under.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Sun, 19 Jan 2020 00:40:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well, it&#39;s easy enough, here&#39;s some code that runs at the beginning of main:</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span>
<span class="number">  2</span><span class="k1">int</span> main<span class="k2">(</span><span class="k1">int</span> argc, <span class="k1">char</span><span class="k3">*</span> argv<span class="k2">[</span><span class="k2">]</span>, <span class="k1">char</span><span class="k3">*</span> envp<span class="k2">[</span><span class="k2">]</span><span class="k2">)</span>
<span class="number">  3</span><span class="k2">{</span>
<span class="number">  4</span>    <span class="c">// first change current dir, that should not relate to this problem though</span>
<span class="number">  5</span>    <span class="k1">char</span> fd_buf<span class="k2">[</span><span class="n">1024</span><span class="k2">]</span><span class="k2">;</span>
<span class="number">  6</span>
<span class="number">  7</span>    <span class="k2">{</span>
<span class="number">  8</span>        <span class="c">// determine where the executable is and change working dir to that directory</span>
<span class="number">  9</span>        <span class="c">// so we can find out ini file later on</span>
<span class="number"> 10</span>        <a href="http://www.delorie.com/djgpp/doc/libc/libc_756.html" target="_blank">strcpy</a><span class="k2">(</span>fd_buf, argv<span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 11</span>        <span class="k1">char</span><span class="k3">*</span>p_slash <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span>
<span class="number"> 12</span>        <span class="k1">for</span><span class="k2">(</span><span class="k1">char</span><span class="k3">*</span>p <span class="k3">=</span> fd_buf<span class="k2">;</span> <span class="k3">*</span>p<span class="k2">;</span> <span class="k3">+</span><span class="k3">+</span>p<span class="k2">)</span>
<span class="number"> 13</span>        <span class="k2">{</span>
<span class="number"> 14</span>            <span class="k1">if</span><span class="k2">(</span><span class="k3">*</span>p <span class="k3">=</span><span class="k3">=</span> ALLEGRO_NATIVE_PATH_SEP<span class="k2">)</span>
<span class="number"> 15</span>                p_slash <span class="k3">=</span> p<span class="k2">;</span>
<span class="number"> 16</span>        <span class="k2">}</span>
<span class="number"> 17</span>        <span class="k1">if</span><span class="k2">(</span>p_slash<span class="k2">)</span>
<span class="number"> 18</span>            <span class="k3">*</span>p_slash <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span>
<span class="number"> 19</span>        <a href="http://www.allegro.cc/manual/al_change_directory"><span class="a">al_change_directory</span></a><span class="k2">(</span>fd_buf<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 20</span>    <span class="k2">}</span>
<span class="number"> 21</span>
<span class="number"> 22</span>    <span class="c">// init allegro</span>
<span class="number"> 23</span>    <a href="http://www.allegro.cc/manual/al_init"><span class="a">al_init</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 24</span>    <a href="http://www.allegro.cc/manual/al_install_keyboard"><span class="a">al_install_keyboard</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 25</span>    <a href="http://www.allegro.cc/manual/al_install_mouse"><span class="a">al_install_mouse</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 26</span>
<span class="number"> 27</span>    <a href="http://www.allegro.cc/manual/al_init_font_addon"><span class="a">al_init_font_addon</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 28</span>    <a href="http://www.allegro.cc/manual/al_init_ttf_addon"><span class="a">al_init_ttf_addon</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 29</span>    <a href="http://www.allegro.cc/manual/al_init_image_addon"><span class="a">al_init_image_addon</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 30</span>    <a href="http://www.allegro.cc/manual/al_init_primitives_addon"><span class="a">al_init_primitives_addon</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 31</span>    al_init_physfs_addon<span class="k2">(</span>argv<span class="k2">[</span><span class="n">0</span><span class="k2">]</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 32</span>
<span class="number"> 33</span>    <span class="c">//... some other configuration like setting up display and such things</span>
<span class="number"> 34</span>
<span class="number"> 35</span>    <span class="k1">if</span><span class="k2">(</span>argc <span class="k3">&lt;</span><span class="k3">=</span> <span class="n">1</span><span class="k2">)</span>
<span class="number"> 36</span>    <span class="k2">{</span>
<span class="number"> 37</span>        <a href="http://www.allegro.cc/manual/ALLEGRO_FILECHOOSER"><span class="a">ALLEGRO_FILECHOOSER</span></a><span class="k3">*</span> pfch <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_create_native_file_dialog"><span class="a">al_create_native_file_dialog</span></a><span class="k2">(</span><span class="s">""</span>, <span class="s">"Select xyz file"</span>, <span class="s">"*.xyz;*.cxyz;*.zip"</span>, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 38</span>        <a href="http://www.allegro.cc/manual/al_show_native_file_dialog"><span class="a">al_show_native_file_dialog</span></a><span class="k2">(</span>p_display, pfch<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 39</span>        <span class="k1">if</span><span class="k2">(</span><a href="http://www.allegro.cc/manual/al_get_native_file_dialog_count"><span class="a">al_get_native_file_dialog_count</span></a><span class="k2">(</span>pfch<span class="k2">)</span> <span class="k3">=</span><span class="k3">=</span> <span class="n">1</span><span class="k2">)</span>
<span class="number"> 40</span>        <span class="k2">{</span>
<span class="number"> 41</span>            <span class="k1">const</span> <span class="k1">char</span><span class="k3">*</span> filename <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_native_file_dialog_path"><span class="a">al_get_native_file_dialog_path</span></a><span class="k2">(</span>pfch, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 42</span>            <a href="http://www.delorie.com/djgpp/doc/libc/libc_756.html" target="_blank">strcpy</a><span class="k2">(</span>fd_buf, filename<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 43</span>        <span class="k2">}</span>
<span class="number"> 44</span>        <span class="k1">else</span>
<span class="number"> 45</span>        <span class="k2">{</span>
<span class="number"> 46</span>            <a href="http://www.delorie.com/djgpp/doc/libc/libc_298.html" target="_blank">exit</a><span class="k2">(</span><span class="k3">-</span><span class="n">1</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 47</span>        <span class="k2">}</span>
<span class="number"> 48</span>    <span class="k2">}</span>
<span class="number"> 49</span>    <span class="k1">else</span>
<span class="number"> 50</span>    <span class="k2">{</span>
<span class="number"> 51</span>        <a href="http://www.delorie.com/djgpp/doc/libc/libc_756.html" target="_blank">strcpy</a><span class="k2">(</span>fd_buf, argv<span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 52</span>    <span class="k2">}</span>
</div></div><p>
So what worked before is that the box showed the matching files, and the button is labelled &quot;Select xyz file&quot;. With the changes the button is correctly labelled, but no files seem to match, so matching files are shown.</p><p>However, when I type &quot;*.xyz&quot; into the selection field, then the matching files appear...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tobing)</author>
		<pubDate>Mon, 20 Jan 2020 15:49:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Alright it is I think because the filter has embedded NULLs in it and my al_ustr-&gt;utf16 conversion didn&#39;t account for that.<br />Filter is assembled in <span class="source-code">create_filter_string</span> (win_dialog.c:128) and conversion is via <span class="source-code">_twin_ustr_to_tchar</span> which you will see assumes a C-style null termination.</p><p>Might be good for the ex_native_filechooser to make use of the filter which it doesn&#39;t currently.</p><p>Haven&#39;t looked at the clipboard thing yet.</p><p>[edit] Please can someone file a bug or bugs? Thanks.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Wed, 22 Jan 2020 03:13:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Good call, Peter! I could reproduce tobings issue with the file dialog, and made a fix based on your observation: <a href="https://github.com/liballeg/allegro5/pull/1114">https://github.com/liballeg/allegro5/pull/1114</a>.</p><p>tobing, would you mind testing it? I also looked at the clipboard stuff, but it didn&#39;t appear to have any obvious issues. Can you explain a bit more what you do there? Are you passing a unicode string to <span class="source-code">al_set_clipboard_text</span>?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Wed, 22 Jan 2020 10:25:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Great. I had written my own fix which was almost word-for-word identical with your PR <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /> . But, does it need fixing for the non-UNICODE build too?</p><p>[edit]<br />On the clipboard, we are always converting <span class="source-code"><a href="http://www.allegro.cc/manual/ALLEGRO_USTR"><span class="a">ALLEGRO_USTR</span></a></span> to UTF-16, but we are setting it onto the clipboard using either CF_UNICODETEXT or CF_TEXT depending on the value of UNICODE. See <a href="https://github.com/liballeg/allegro5/blob/36c1549bae816c35a79d9a842beb777bde4b4a28/src/win/wclipboard.c#L91">https://github.com/liballeg/allegro5/blob/36c1549bae816c35a79d9a842beb777bde4b4a28/src/win/wclipboard.c#L91</a></p><p>I think regardless of the value UNICODE used when compiling Allegro, we should be using CF_UNICODETEXT as I don&#39;t think there are supported non-unicode-aware versions of Windows any more. (Windows ME?)<br />What do you think?<br />Also there is probably something equally wrong on the &#39;paste&#39; side.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Wed, 22 Jan 2020 13:23:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/618026/1044683#target">Peter Hull</a> said:</div><div class="quote"><p> But, does it need fixing for the non-UNICODE build too?</p></div></div><p>I thought we decided to get rid of the ANSI code path? We could still add it in the meantime, I suppose.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p> On the clipboard, we are always converting ALLEGRO_USTR to UTF-16, but we are setting it onto the clipboard using either CF_UNICODETEXT or CF_TEXT depending on the value of UNICODE.</p></div></div><p>Interesting. That does look wrong for the non-UNICODE case, but the UNICODE path seems fine, no? The only way to compile Allegro with ANSI is to edit the CMakeLists.txt, and that seems unlikely to have happened in this case.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Wed, 22 Jan 2020 22:12:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/618026/1044687#target">SiegeLord</a> said:</div><div class="quote"><p> and that seems unlikely to have happened in this case. 
</p></div></div><p>Tobing did say he was using MBCS, in the first post. But I agree, there should be no reason not to use Unicode these days.</p><p>Actually, I mis-remembered - I thought it was easy to build a non-Unicode version but, as you say, it does require editing the CMake files. How are you building Allegro, tobing?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Thu, 23 Jan 2020 00:10:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sorry, I was a bit captured by something else for some days. Thanks for looking into it.</p><p>I&#39;m using more or less hand-made visual studio 2017 projects, and the settings are the same for allegro and all the other libraries I&#39;m building this way. Almost all is statically linked, and I also have zip png jpg ogg lua freetype physfs alguichan in the boat. So it won&#39;t be easy to share the exact configuration, but I think I could extract the typical parameter lines for compiler and linker, if needed.</p><p>I&#39;ll try to figure out how to check out the fix you provided, so I can test it.</p><p>For the copy&amp;paste, most of the time I&#39;m pasting into an empty Notepad++ tab, and sometimes into outlook mail directly, without difference in behavior - either both work fine, or they don&#39;t. For the question about how I copy the text into the clipboard, I&#39;ll have to look up the code...</p><p>Edit: checked out your change, and tested. When I finally compiled allegro, aladdons and the main program with UNICODE, the fix worked. So that&#39;s nice, but to be honest, why doesn&#39;t it also work when I don&#39;t use UNICODE? Seems that the code uses _al_win_utf8_to_ansi instead of _al_win_utf8_to_utf16 which has been replaced by your change, so maybe the MBCS-part also needs some fix?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tobing)</author>
		<pubDate>Mon, 27 Jan 2020 15:51:46 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/618026/1044748#target">tobing</a> said:</div><div class="quote"><p>  but to be honest, why doesn&#39;t it also work when I don&#39;t use UNICODE? </p></div></div><p>The reason is simply that SL&#39;s patch didn&#39;t make any changes to the non-Unicode code path. </p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/618026/1044683#target">Peter Hull</a> said:</div><div class="quote"><p>  But, does it need fixing for the non-UNICODE build too?</p></div></div><p>I believe we are on the verge of making the Unicode version the only version - all supported Windows use Unicode internally and all Allegro&#39;s string handling works via UTF-8. However it would not be too difficult to maintain if you&#39;ve got a good reason for not using Unicode?</p><p>Thanks,<br />Pete
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Mon, 27 Jan 2020 20:01:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I see, it&#39;s a custom built Allegro, things are starting to make sense! I&#39;d still love to hear more about what&#39;s done to hit the clipboard bug.</p><p>We could certainly keep the ANSI versions around, in principle, thanks to Peter&#39;s hard work it&#39;s essentially free. It&#39;s easy to fix the file dialog for ANSI as well, I just didn&#39;t do it since I didn&#39;t know you were compiling Allegro in ANSI mode yourself.</p><p>EDIT: I added the implementation of the fix for ANSI as well.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Tue, 28 Jan 2020 09:00:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The extended fix solves the issues with the file selection box, both UNICODE and MBCS.</p><p>About the question why I used MBCS, there&#39;s no reason in particular, just used to have that setting all the time and didn&#39;t need to change it. But switching to UNICODE for everything I do (with allegro) is certainly possible, and I think I&#39;ll do that for future builds. Because when I&#39;m using strings and text (also from files), I&#39;m thinking UTF8 actually.</p><p>The clipboard thing is a different story. Works with UNICODE, but does not work with MBCS. I&#39;ll check the details and come back with more information, especially about how I feed my string into the clipboard...</p><p>Thanks a lot for the file selection box fix!!!</p><p>Edit:</p><p>I#m using al_set_clipboard_text with a char* grom a std::string. Some debugging shows that the string is converted using _al_win_utf8_to_utf16 and a few lines later, memmove is used to copy/move the bytes to the dst buffer. There&#39;s no obvious difference between UNICODE and MBCS, except that <u>after</u> the memmove, in case of UNICODE, the dst string looks correct, while with MBCS the dst string only shows the first character, even though all bytes have been moved...</p><p>That brought me onto the right track, so here&#39;s the changed method that works for both UNICODE and MBCS:</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span><span class="k1">static</span> <span class="k1">bool</span> win_set_clipboard_text<span class="k2">(</span><a href="http://www.allegro.cc/manual/ALLEGRO_DISPLAY"><span class="a">ALLEGRO_DISPLAY</span></a> <span class="k3">*</span>display, <span class="k1">const</span> <span class="k1">char</span> <span class="k3">*</span>text<span class="k2">)</span>
<span class="number">  2</span><span class="k2">{</span>
<span class="number">  3</span>   HWND handle <span class="k3">=</span> get_window_handle<span class="k2">(</span>display<span class="k2">)</span><span class="k2">;</span>
<span class="number">  4</span>   HANDLE hMem <span class="k3">=</span> NULL<span class="k2">;</span>
<span class="number">  5</span><span class="p">#ifdef UNICODE</span>
<span class="number">  6</span>   <span class="k1">wchar_t</span> <span class="k3">*</span>tstr <span class="k3">=</span> NULL<span class="k2">;</span>
<span class="number">  7</span><span class="p">#else</span>
<span class="number">  8</span>   <span class="k1">char</span> <span class="k3">*</span>tstr <span class="k3">=</span> NULL<span class="k2">;</span>
<span class="number">  9</span><span class="p">#endif</span>
<span class="number"> 10</span>   <span class="k1">size_t</span> size<span class="k2">;</span>
<span class="number"> 11</span>   <span class="k1">size_t</span> len<span class="k2">;</span>
<span class="number"> 12</span>   LPTSTR dst<span class="k2">;</span>
<span class="number"> 13</span>
<span class="number"> 14</span>   <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span>OpenClipboard<span class="k2">(</span>handle<span class="k2">)</span><span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 15</span>      ALLEGRO_DEBUG<span class="k2">(</span><span class="s">"Could not open clipboard for handle %p"</span>, handle<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 16</span>      <span class="k1">return</span> <span class="k1">false</span><span class="k2">;</span>
<span class="number"> 17</span>   <span class="k2">}</span>
<span class="number"> 18</span>
<span class="number"> 19</span>   <span class="c">/* Convert the text from UTF-8 to Windows Unicode */</span>
<span class="number"> 20</span><span class="p">#ifdef UNICODE</span>
<span class="number"> 21</span>   tstr <span class="k3">=</span> _al_win_utf8_to_utf16<span class="k2">(</span>text<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 22</span>   len <span class="k3">=</span> wcslen<span class="k2">(</span>tstr<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 23</span>   size <span class="k3">=</span> <span class="k2">(</span>len <span class="k3">+</span> <span class="n">1</span><span class="k2">)</span> <span class="k3">*</span> <span class="k1">sizeof</span><span class="k2">(</span><span class="k1">wchar_t</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 24</span><span class="p">#else</span>
<span class="number"> 25</span>   tstr <span class="k3">=</span> _al_win_utf8_to_ansi<span class="k2">(</span>text<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 26</span>   len <span class="k3">=</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_764.html" target="_blank">strlen</a><span class="k2">(</span>tstr<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 27</span>   size <span class="k3">=</span> len <span class="k3">+</span> <span class="n">1</span><span class="k2">;</span>
<span class="number"> 28</span><span class="p">#endif</span>
<span class="number"> 29</span>   <span class="c">/* Save the data to the clipboard */</span>
<span class="number"> 30</span>   hMem <span class="k3">=</span> GlobalAlloc<span class="k2">(</span>GMEM_MOVEABLE, size<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 31</span>
<span class="number"> 32</span>   <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span>hMem<span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 33</span>      <a href="http://www.allegro.cc/manual/al_free"><span class="a">al_free</span></a><span class="k2">(</span>tstr<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 34</span>      ALLEGRO_DEBUG<span class="k2">(</span><span class="s">"GlobalAlloc failed to allocate memory for the clipboard data"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 35</span>      <span class="k1">return</span> <span class="k1">false</span><span class="k2">;</span>
<span class="number"> 36</span>   <span class="k2">}</span>
<span class="number"> 37</span>
<span class="number"> 38</span>   dst <span class="k3">=</span> <span class="k2">(</span>LPTSTR<span class="k2">)</span>GlobalLock<span class="k2">(</span>hMem<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 39</span>   <span class="c">/* Copy the text over. Unlike SDL, do NOT convert newlines, that's for the</span>
<span class="number"> 40</span><span class="c">    * use to decide. */</span>
<span class="number"> 41</span>   <a href="http://www.delorie.com/djgpp/doc/libc/libc_568.html" target="_blank">memmove</a><span class="k2">(</span>dst, tstr, size<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 42</span>   dst<span class="k2">[</span>len<span class="k2">]</span> <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span>
<span class="number"> 43</span>   GlobalUnlock<span class="k2">(</span>hMem<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 44</span>   EmptyClipboard<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 45</span>   <span class="k1">if</span> <span class="k2">(</span><span class="k3">!</span>SetClipboardData<span class="k2">(</span>TEXT_FORMAT, hMem<span class="k2">)</span><span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 46</span>      <a href="http://www.allegro.cc/manual/al_free"><span class="a">al_free</span></a><span class="k2">(</span>tstr<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 47</span>      ALLEGRO_DEBUG<span class="k2">(</span><span class="s">"Couldn't set clipboard data"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 48</span>      <span class="k1">return</span> <span class="k1">false</span><span class="k2">;</span>
<span class="number"> 49</span>   <span class="k2">}</span>
<span class="number"> 50</span>   <a href="http://www.allegro.cc/manual/al_free"><span class="a">al_free</span></a><span class="k2">(</span>tstr<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 51</span>   CloseClipboard<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 52</span>   <span class="k1">return</span> <span class="k1">true</span><span class="k2">;</span>
<span class="number"> 53</span><span class="k2">}</span>
</div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tobing)</author>
		<pubDate>Wed, 29 Jan 2020 14:57:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Great, makes sense! But might need a bit more thought about edge-cases etc.</p><p>Also the API/docs are a bit vague, <span class="source-code">al_set_clipboard_text</span> takes <span class="source-code"><span class="k1">const</span> <span class="k1">char</span><span class="k3">*</span></span> which has to be UTF-8 but the docs don&#39;t say that - if you were writing ansi code with a specific code-page and using characters &gt; 127 it would fail.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Wed, 29 Jan 2020 21:32:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks for the fixes!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tobing)</author>
		<pubDate>Sun, 02 Feb 2020 14:00:53 +0000</pubDate>
	</item>
</rss>
