<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Getting portuguese to work with al_draw_text</title>
		<link>http://www.allegro.cc/forums/view/609988</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 12 Apr 2012 07:40:13 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi,</p><p>I&#39;m brazilian, and as such, I am inclined to make pt-br versions of my games. But as you guys may know(or not), portuguese words may, or may not, have accents in them, such as &quot;áàéíóúêôã&quot;(can&#39;t tell if you&#39;ll be able to see these characters).</p><p>Witch brings to my problem. What happens when I try printing &quot;Isto é uma frase&quot; with al_draw_text, is the function printing &quot;Isto &quot;. The function aborts at the first character it doesn&#39;t know(but it <b>is</b> described in the TTF font), and prints only the first characters before it.</p><p>My question is: Is there any way to get around this? Will support for other languages be added in future releases?</p><p>Thanks!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Cassio Renan)</author>
		<pubDate>Wed, 11 Apr 2012 05:04:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If your text is in UTF8 format, and the font has the characters you need, it will work. I have a Brazilian Portuguese translation in my game and it works. I use DejaVu Sans but any font with those characters should work. Just make sure the text is encoded as UTF8.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Wed, 11 Apr 2012 05:35:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I feel really stupid. the Allegro UTF-8 routines take like, 30 pages of the reference manual. Thanks Trent, if you hadn&#39;t replied I wouldn&#39;t have seen it.<br />I&#39;m trying to use allegro routines, but can&#39;t get them to work. Tried googling for some time(and even got to this nice <a href="http://www.joelonsoftware.com/articles/Unicode.html">article</a>) with no success. Is there any particular way I should be handling the strings? the code:
</p><div class="source-code snippet"><div class="inner"><pre><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">"Isto é uma linha"</span><span class="k2">)</span><span class="k2">;</span>
</pre></div></div><p>

or</p><div class="source-code snippet"><div class="inner"><pre><a href="http://www.allegro.cc/manual/al_ustr_new"><span class="a">al_ustr_new</span></a><span class="k2">(</span>random_c_string<span class="k2">)</span><span class="k2">;</span> <span class="c">// any random string with 'accented' chars</span>
</pre></div></div><p>

doesn&#39;t seem to work. I know I can keep the code points in a header file full of defines, like:</p><div class="source-code snippet"><div class="inner"><pre><span class="p">#define U_ae         0x00e6   /* æ */</span>
<span class="p">#define U_i_acute    0x00ed   /* í */</span>
<span class="p">#define U_eth        0x00f0   /* ð */</span>
<span class="p">#define U_o_dia      0x00f6   /* ö */</span>
<span class="p">#define U_thorn      0x00fe   /* þ */</span>
<span class="p">#define U_z_bar      0x01b6   /* ƶ */</span>
<span class="p">#define U_schwa      0x0259   /* ə */</span>
<span class="p">#define U_beta       0x03b2   /* β */</span>
<span class="p">#define U_1d08       0x1d08   /* ᴈ */</span>
<span class="p">#define U_1ff7       0x1ff7   /* ῷ */</span>
<span class="p">#define U_2051       0x2051   /* ⁑ */</span>
<span class="p">#define U_euro       0x20ac   /* € */</span>
</pre></div></div><p>

And write a function to push them into a ALLEGRO_USTR using a regular c string and a switch, but I <b>know</b> there is a better way of doing this.</p><p>Any help?<br />Thanks!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Cassio Renan)</author>
		<pubDate>Wed, 11 Apr 2012 09:09:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>When you save your source file with whatever text editor you&#39;re using, save it with UTF8 encoding. If your text editor can&#39;t do that, get one that can. For Windows Notepad++ (free) can convert between encodings. On Mac, Textwrangler (free) and probably something like gedit or kate can on Linux but I&#39;m not sure there.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Wed, 11 Apr 2012 09:12:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That&#39;s the problem. I use Visual Studio 2010 Express on Windows, and all my source code is alredy encoded in UTF-8(just checked it, and the character &#39;é&#39; occupies 2 bytes, as it is supposed to). I know that&#39;s a problem with C strings(they only allow 1 byte per char, witch means my compiler is probably converting the string into ASCII before building, i guess). Is there any configuration I&#39;m missing? I just gone into a crazy &quot;check unicode&quot; rampage on every configuration field I could into the project options.</p><p>And thanks for the help, I really appreciate it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Cassio Renan)</author>
		<pubDate>Thu, 12 Apr 2012 00:56:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>MSVC is indeed troublesome in this regard. I believe you need to remove the UTF-8 BOM (byte order mark) on your source files (and make sure they never come back!) so that MSVC treats your files as an 8-bit encoding. I couldn&#39;t find an option to convince the compiler to leave the strings alone otherwise.</p><p>Apparently you can install this hotfix <a href="http://support.microsoft.com/kb/980263">http://support.microsoft.com/kb/980263</a> then use
</p><div class="source-code snippet"><div class="inner"><pre><span class="p">#pragma execution_character_set("utf-8")</span>
</pre></div></div><p>

A more robust but tedious way is to externalise your accented strings and use only ASCII string literals in your source. C11 introduces the u8 prefix on string literals but that doesn&#39;t help for now.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Wang)</author>
		<pubDate>Thu, 12 Apr 2012 04:53:33 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>This must be the most hilarious solution I&#39;ve ever seen to a problem.<br />I changed my source files encoding to ANSI(ASCII) using notepad++ (whithout converting from UTF-8, witch made &#39;é&#39; turn into &#39;Ã©&#39;) and then loaded them again on MSVC.<br />MSVC probably recognized as ASCII and not tried to convert it. Like you said. It worked.</p><p>I&#39;m really amazed.</p><p>PS.:Unfortunately, the hotfix only works for MSVC 2008, and I use 2010.</p><p>Thanks!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Cassio Renan)</author>
		<pubDate>Thu, 12 Apr 2012 07:40:13 +0000</pubDate>
	</item>
</rss>
