<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Internationalization</title>
		<link>http://www.allegro.cc/forums/view/610238</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 17 May 2012 11:29:53 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>How do you guys (especially non-USA residents) handle the wide variety of standards for Unicode type stuff?</p><p>Imagine a little scenario where you have a FPS game and you want to have a screen that maps the controls to the next keypress?  I get the idea that accented European chars need two keypresses, so they&#39;d never register (?), but what if the player was from Asia?  How would the confirmation character be displayed?  As a hex character if it wasn&#39;t in the font being used?</p><p>Cookies for sensible, easy to understand answers (if such answers don&#39;t exist, then everybody who doesn&#39;t troll gets a cookie)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Tue, 15 May 2012 23:45:14 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>For text input, Allegro5 handles that relatively nicely via the ALLEGRO_EVENT_KEY_CHAR event. It doesn&#39;t handle the custom Unicode entry (Ctrl+Shift+U), but it does work with the compose key.</p><p>For everything else, I&#39;d map the keycodes (which stay the same regardless of what they are mapped to, I think) to actions. For display purposes you&#39;d need some way to map keycode to what&#39;s written on the keyboard, but that is a secondary issue.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Wed, 16 May 2012 00:06:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>What SiegeLord said. For example to have left/right movement, ask the player to press the key for moving left, then listen for the next ALLEGRO_EVENT_KEY_DOWN. Whatever keycode it was should be used for the &quot;move left&quot; action.</p><p>If it is ALLEGRO_KEY_Z then that does not mean the key has a &quot;z&quot; painted on it. It will have a &quot;y&quot; on a German keyboard and a &quot;w&quot; on a French keyboard and possibly something else entirely on other keyboards. But it doesn&#39;t matter - it will just work.</p><p>The only time internationalization is a problem is if you hard-code ALLEGRO_KEY_Z into your game. That will break.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Wed, 16 May 2012 00:18:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Right now I have:
</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">case</span> ALLEGRO_EVENT_KEY_CHAR:
<span class="number">  2</span>        <span class="k2">{</span>
<span class="number">  3</span>          <span class="k1">char</span> c<span class="k2">;</span>
<span class="number">  4</span>          c <span class="k3">=</span> event.keyboard.unichar<span class="k2">;</span>
<span class="number">  5</span>          <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"%c 0x%X\n"</span>,c,c<span class="k2">)</span><span class="k2">;</span>
<span class="number">  6</span>          <a href="http://www.delorie.com/djgpp/doc/libc/libc_315.html" target="_blank">fflush</a><span class="k2">(</span>stdout<span class="k2">)</span><span class="k2">;</span>
<span class="number">  7</span>          <span class="k1">break</span><span class="k2">;</span>
<span class="number">  8</span>        <span class="k2">}</span>
<span class="number">  9</span>        
<span class="number"> 10</span>        <span class="k1">case</span> ALLEGRO_EVENT_KEY_DOWN:
<span class="number"> 11</span>          <span class="k1">if</span> <span class="k2">(</span>event.keyboard.keycode <span class="k3">=</span><span class="k3">=</span> ALLEGRO_KEY_ESCAPE<span class="k2">)</span>
<span class="number"> 12</span>          <span class="k1">goto</span> done<span class="k2">;</span>
<span class="number"> 13</span>          key_array<span class="k2">[</span>event.keyboard.keycode<span class="k2">]</span> <span class="k3">=</span> <span class="k1">true</span><span class="k2">;</span>
<span class="number"> 14</span>          <span class="k1">break</span><span class="k2">;</span>
<span class="number"> 15</span>
<span class="number"> 16</span>        <span class="k1">case</span> ALLEGRO_EVENT_KEY_UP:
<span class="number"> 17</span>          key_array<span class="k2">[</span>event.keyboard.keycode<span class="k2">]</span> <span class="k3">=</span> <span class="k1">false</span><span class="k2">;</span>
<span class="number"> 18</span>          <span class="k1">break</span><span class="k2">;</span>
</div></div><p>
and I was imagining using the key_array[] for movement, etc.  The ALLEGRO_EVENT_KEY_CHAR is just an experiment based on what SiegeLord said.</p><p>OTOH, I have a word wrap function using char buffers (for largish text files to be displayed in a box with a scroll bar) that looks for &#39;\n&#39; to start a new line, else it casts it to an unsigned char and ignores everything below &#39; &#39;.  I tried it with a couple of weird accented strings from Google Translate to see if it&#39;d do anything unexpected, but it hasn&#39;t done anything but ignore chars with the high bit set yet.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Wed, 16 May 2012 00:26:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes, that key_array will work fine on any international keyboards (as long as you let the user press the keys to obtain the keycodes and don&#39;t hardcode anything).</p><p>The event.keyboard.unichar gives you the unicode number, so you need to store it in an int and not a char. And to print use:</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">int</span> c <span class="k3">=</span> event.keyboard.unichar<span class="k2">;</span>
<a href="http://www.allegro.cc/manual/ALLEGRO_USTR"><span class="a">ALLEGRO_USTR</span></a> <span class="k3">*</span>u <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_ustr_new"><span class="a">al_ustr_new</span></a><span class="k2">(</span><span class="s">""</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_ustr_append_chr"><span class="a">al_ustr_append_chr</span></a><span class="k2">(</span>u, c<span class="k2">)</span><span class="k2">;</span>
<a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"%s\n"</span>, <a href="http://www.allegro.cc/manual/al_cstr"><span class="a">al_cstr</span></a><span class="k2">(</span>u<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<a href="http://www.allegro.cc/manual/al_ustr_free"><span class="a">al_ustr_free</span></a><span class="k2">(</span>u<span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

This makes sure it&#39;s encoded into an UTF8 string which printf (at least under Linux) should understand. Otherwise use Allegro&#39;s text functions which have UTF8 as input.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Wed, 16 May 2012 01:41:06 +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/610238/954964#target">Elias</a> said:</div><div class="quote"><p> The event.keyboard.unichar gives you the unicode number, so you need to store it in an int and not a char. And to print use:</p></div></div><p>Yhea, an unicode number may consist in one, two, up to four bytes.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (AMCerasoli)</author>
		<pubDate>Wed, 16 May 2012 02:00:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>So I&#39;m clicking on the links to the manual, and looking at ex_utf8.c in my text editor...</p><p><span class="remote-thumbnail"><span class="json">{"name":"606033","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/f\/5fde498aba429ad8a340509ef64f9d31.png","w":710,"h":229,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/f\/5fde498aba429ad8a340509ef64f9d31"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/5/f/5fde498aba429ad8a340509ef64f9d31-240.jpg" alt="606033" width="240" height="77" /></span></p><p>This sort of thing doesn&#39;t make it any easier.</p><p>I&#39;ll try to make a little example program for people to test in another thread eventually.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Wed, 16 May 2012 02:10:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Is your text editor using UTF-8?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (AMCerasoli)</author>
		<pubDate>Wed, 16 May 2012 02:15:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m using KWrite, under Settings | Configure Editor | File Opening and Saving | General there&#39;s a dropdown list set for &quot;Encoding Detection: Universal&quot; and a &quot;Fallback Encoding&quot; which I set to &quot;Unicode (UTF-8)&quot; but ex_utf8.c still looks the same.  IIRC, there&#39;s some sort of configuration file somewhere to set colors for comments etc. (maybe an earlier version of Kwrite or some other editor entirely) but I can&#39;t find it now.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Wed, 16 May 2012 02:27:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well if it&#39;s not an encoding problem then maybe the fonts that it&#39;s using the editor doesn&#39;t know those symbols... <img src="http://www.allegro.cc/forums/smileys/undecided.gif" alt=":-/" /> Generally it should just place a rectangle (█) or some weird symbol, but since it&#39;s putting those weird (Asiatic?) letters I still thinking is trying to encode the text with the wrong encoding format.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (AMCerasoli)</author>
		<pubDate>Wed, 16 May 2012 02:35:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I tried with quite a few others just now, and it looks like either one of the red circled areas except for Kword which showed some weird XML looking stuff.  I would assume the &quot;1/8th note&quot; thing is supposed to be followed by what looks like an actual music note (blob at the bottom of a vertical line with a flag on top) but I haven&#39;t seen that yet.</p><p>[EDIT]</p><p>I tried the code snippet Elias provided, and it seemed to work OK until I exited the program and the bit at the end that prints FPS ranged from 0.0 to 9.9 when the timer is set to 60FPS.  Weird.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Wed, 16 May 2012 02:38:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I don&#39;t know man... I think it&#39;s just a problem with the fonts, this how it looks on C::B:</p><p><span class="remote-thumbnail"><span class="json">{"name":"606034","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/b\/db946abacf67e34573a16cd16b9b1ceb.png","w":989,"h":283,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/b\/db946abacf67e34573a16cd16b9b1ceb"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/d/b/db946abacf67e34573a16cd16b9b1ceb-240.jpg" alt="606034" width="240" height="68" /></span></p><p>If you&#39;ll be showing those kind of symbols then you need to find a super font with all those symbols.</p><p><b>Edit:</b>... Uh?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (AMCerasoli)</author>
		<pubDate>Wed, 16 May 2012 02:49:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Here is the ⅛ note. I guess it&#39;s pretty rare. I don&#39;t see it either.</p><p><a href="http://www.fileformat.info/info/unicode/char/1d160/index.htm">http://www.fileformat.info/info/unicode/char/1d160/index.htm</a></p><p>I tried KWrite here as well. While it looks better than in Arthur&#39;s screenshot, it&#39;s broken in another way (notice the two dominos, and editing on that line is broken). The rest of the file seems to be okay, so it&#39;s probably a problem with surrogate code points. (Don&#39;t worry about it.)</p><p><span class="remote-thumbnail"><span class="json">{"name":"606035","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/5\/3535b780368629ca419305502c393f89.png","w":701,"h":418,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/3\/5\/3535b780368629ca419305502c393f89"}</span><img src="http://www.allegro.cc//djungxnpq2nug.cloudfront.net/image/cache/3/5/3535b780368629ca419305502c393f89-240.jpg" alt="606035" width="240" height="143" /></span>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Wang)</author>
		<pubDate>Wed, 16 May 2012 05:22:47 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Does al_ustr_new() reallocate space as needed?  I see a vector.c which seems to be for this purpose alongside bstrlib.c.  Since I don&#39;t want to make a career out of deciphering all this stuff I thought I&#39;d ask this here.  The documentation doesn&#39;t seem to say this.  FWIW, I did a
</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> u <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_ustr_new"><span class="a">al_ustr_new</span></a><span class="k2">(</span><span class="s">""</span><span class="k2">)</span><span class="k2">;</span>
<span class="number">  2</span>  .
<span class="number">  3</span>  .
<span class="number">  4</span>  .
<span class="number">  5</span> <span class="k2">(</span>event loop<span class="k2">)</span>
<span class="number">  6</span>        <span class="k1">case</span> ALLEGRO_EVENT_KEY_CHAR:
<span class="number">  7</span>        <span class="k2">{</span>
<span class="number">  8</span>          <span class="k1">int</span> c<span class="k2">;</span>
<span class="number">  9</span>          <span class="k1">if</span><span class="k2">(</span>inputtext <span class="k3">=</span><span class="k3">=</span> <span class="n">0</span><span class="k2">)</span>
<span class="number"> 10</span>            <span class="k1">break</span><span class="k2">;</span>
<span class="number"> 11</span>          c <span class="k3">=</span> event.keyboard.unichar<span class="k2">;</span>
<span class="number"> 12</span>          <a href="http://www.allegro.cc/manual/al_ustr_append_chr"><span class="a">al_ustr_append_chr</span></a><span class="k2">(</span>u, c<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 13</span>          <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"%s\n"</span>, <a href="http://www.allegro.cc/manual/al_cstr"><span class="a">al_cstr</span></a><span class="k2">(</span>u<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 14</span>          <span class="k1">break</span><span class="k2">;</span>
<span class="number"> 15</span>        <span class="k2">}</span>
</div></div><p>
and got it up to over 5000 chars before each instance of the string filled the console and it didn&#39;t crash.</p><p>[EDIT]</p><p>I should have asked &quot;Does al_ustr_append_chr() reallocate space as needed?&quot;
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Wed, 16 May 2012 13:36:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Wang)</author>
		<pubDate>Wed, 16 May 2012 15:30:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thank you!  I guess I can proceed now.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Wed, 16 May 2012 15:32:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You just need a font that has the missing Unicode glyphs. The one where you see the 1/8 glyph is probably correct; the reason you don&#39;t see the other glyphs is, most likely, that none of the fonts you X11 knows contains them. You can try looking the glyph up in some character map program to see if it&#39;s there (gnome-charmap is OK, but if you&#39;re more of a KDE guy, I&#39;m sure they have something similar).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Thu, 17 May 2012 11:29:53 +0000</pubDate>
	</item>
</rss>
