<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>al_draw_text() and special characters</title>
		<link>http://www.allegro.cc/forums/view/611123</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Thu, 27 Sep 2012 01:40:59 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hey, i&#39;m currently working on some sort of game-engine for a school project.<br />But i have some troubles with the al_draw_text() function. The problem is, that i can&#39;t print special characters (especially ä,ö and ü), which are used often in german.<br />I already tried stuff like char(129) or &quot;\x81&quot; but it didn&#39;t work.<br />I also found the function al_draw_ustr(), but i never did anything with unicode and i&#39;m not sure how it works.<br />Is there a way to print these characters?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (DrFail)</author>
		<pubDate>Mon, 24 Sep 2012 19:58:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m far from expert, but I&#39;d think <a href="http://www.allegro.cc/manual/5/al_ustr_new_from_buffer">al_ustr_new_from_buffer()</a> would work.  You&#39;d have to free the utf string yourself to avoid memory leaks.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Mon, 24 Sep 2012 20:05:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><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>string text <span class="k3">=</span> <span class="s">"äöüÄÖÜ"</span><span class="k2">;</span>
<span class="number"> 2</span><a href="http://www.allegro.cc/manual/ALLEGRO_USTR"><span class="a">ALLEGRO_USTR</span></a><span class="k3">*</span> uText <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>text.c_str<span class="k2">(</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 3</span><a href="http://www.allegro.cc/manual/al_draw_ustr"><span class="a">al_draw_ustr</span></a><span class="k2">(</span>myFont, myColor, <span class="n">42</span>, <span class="n">42</span>, <span class="n">0</span>, uText<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 4</span><a href="http://www.allegro.cc/manual/al_ustr_free"><span class="a">al_ustr_free</span></a><span class="k2">(</span>uText<span class="k2">)</span><span class="k2">;</span>
</div></div><p>

This would do the same as al_draw_text(), but print the special characters?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (DrFail)</author>
		<pubDate>Mon, 24 Sep 2012 21:25:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>al_draw_text can print special characters just fine (e.g. this is demonstrated in the ex_tff). There are two possible issues which might break it in your case.</p><p>1. Your source file must be encoded using UTF-8<br />2. Your font must have glyphs for those special characters</p><p>Now... you say that you tried explicit unicode characters... so perhaps it&#39;s the second issue?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Mon, 24 Sep 2012 21:38:20 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>When I use<br />al_draw_text(myFont, myColor, 42, 42, 0, &quot;test_ä_end&quot;);<br />the output is just &quot;test_&quot;. The rest is missing.<br />But I&#39;m pretty sure that the font (arial.ttf) has those letters.</p><p>Maybe it&#39;s the first case. I&#39;m using <a href="http://orwelldevcpp.blogspot.ch">Dev-C++ 5.3</a>, but i don&#39;t know if it uses UTF-8.</p><p>Is there a way to find out?<br />Or any other possible solution?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (DrFail)</author>
		<pubDate>Mon, 24 Sep 2012 22:11:01 +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/611123/966732#target">DrFail</a> said:</div><div class="quote"><p> Is there a way to find out?<br /> Or any other possible solution?
</p></div></div><p>Nobody uses DevCpp, so there&#39;s no way to find out. The workabout that always works is to load the strings from a separate file which is UTF-8 encoded (you can be sure of that by using an editor that explicitly allows the option). This is in fact what ex_ttf does for MSVC compatibility.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Tue, 25 Sep 2012 23:32:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I just messed around a little and luckily found a solution <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /><br />With the escape sequence &quot;\u&quot; it&#39;s possible to print the letters.</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>string test <span class="k3">=</span> <span class="s">"test \u00E4\u00C4\u00F6\u00D6\u00FC\u00DC end"</span><span class="k2">;</span>
<span class="number"> 2</span><a href="http://www.allegro.cc/manual/al_draw_text"><span class="a">al_draw_text</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/font"><span class="a">font</span></a>, color, <span class="n">42</span>, <span class="n">42</span>, <span class="n">0</span>, test.c_str<span class="k2">(</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
</div></div><p>
This does exactly what i wanted.</p><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/611123/966856#target">SiegeLord</a> said:</div><div class="quote"><p>... load the strings from a separate file which is UTF-8 encoded.</p></div></div><p>
Good you mentioned that.<br />This makes it possible to get text from files with with special characters and print it on the screen, without extra code.</p><p>Thanks for the help!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (DrFail)</author>
		<pubDate>Thu, 27 Sep 2012 01:40:59 +0000</pubDate>
	</item>
</rss>
