<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>One hand clapping &#187; mutt</title>
	<atom:link href="http://warped.org/blog/tag/mutt/feed/" rel="self" type="application/rss+xml" />
	<link>http://warped.org/blog</link>
	<description>Max Baker -- A Man with a Hand</description>
	<lastBuildDate>Fri, 08 Apr 2011 22:01:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Getting Accents / UTF8 in Mutt using Xterm with TrueType</title>
		<link>http://warped.org/blog/2009/06/08/getting-accents-utf8-in-mutt-using-xterm-with-truetype/</link>
		<comments>http://warped.org/blog/2009/06/08/getting-accents-utf8-in-mutt-using-xterm-with-truetype/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 21:43:16 +0000</pubDate>
		<dc:creator>max</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[mutt]]></category>
		<category><![CDATA[perl6]]></category>
		<category><![CDATA[truetype]]></category>
		<category><![CDATA[utf8]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[xterm]]></category>

		<guid isPermaLink="false">http://warped.org/blog/?p=68</guid>
		<description><![CDATA[Overview I&#8217;m starting to adopt Unicode/UTF-8 into my world to allow for more internationalization in my projects. Someday I might play with Perl6&#8242;s UTF-8 stuff too. I also want to be able have different charactersets render correctly while using Mutt. I often get email from people in Western Europe, Eastern Europe, and SouthEast Asia, and [...]]]></description>
			<content:encoded><![CDATA[<h1>Overview</h1>
<p>I&#8217;m starting to adopt Unicode/UTF-8 into my world to allow for more internationalization in my projects.  Someday I might play with Perl6&#8242;s UTF-8 stuff too.  I also want to be able have different charactersets render correctly while using Mutt.  I often get email from people in Western Europe, Eastern Europe, and SouthEast Asia, and they are all using different character sets.  UTF-8 is the &#8220;universal&#8221; one.</p>
<div id="attachment_73" class="wp-caption alignnone" style="width: 509px"><a href="http://warped.org/blog/wp-content/uploads/2009/06/mutt_utf8.png"><img src="http://warped.org/blog/wp-content/uploads/2009/06/mutt_utf8.png" alt="Shows Hebrew, Chinese and Western European characters all at the same time." title="Mutt in UTF-8 Mode" width="499" height="388" class="size-full wp-image-73" /></a><p class="wp-caption-text">Shows Hebrew, Chinese and Western European characters all at the same time.</p></div>
<h1>The Components</h1>
<h2>Xterm</h2>
<p>In order to have a nice playing Xterm with UTF-8, 256-colors and TrueType, I have to roll my own.</p>
<ol>
<li>Download the latest one from <a href="ftp://invisible-island.net/xterm/xterm.tar.gz">ftp://invisible-island.net/xterm/xterm.tar.gz</a>.
</li>
<li>Compile it

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>configure \
     <span style="color: #660033;">--disable-desktop</span> \
     <span style="color: #660033;">--with-x</span> \
     <span style="color: #660033;">--enable-256-color</span> \
     <span style="color: #660033;">--enable-load-vt-fonts</span> \
     <span style="color: #660033;">--enable-paste64</span> \
     <span style="color: #660033;">--enable-readline-mouse</span> \
     <span style="color: #660033;">--enable-tcap-fkeys</span> \
     <span style="color: #660033;">--enable-tcap-query</span> \
     <span style="color: #660033;">--enable-wide-chars</span> \
     <span style="color: #660033;">--with-Xaw3d</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>Note the crucial <b>&#8211;enable-wide-chars</b> needed for UTF-8.  Your xterm may already be compiled with some or all of these options.
</li>
</ol>
<p>Once I have that, I create a small shell script that I call <b>xt</b> that launches it for me :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;"># None of these have extended charsets :-(</span>
<span style="color: #007800;">font</span>=<span style="color: #ff0000;">&quot;Consolas&quot;</span>
<span style="color: #666666; font-style: italic;">#font=&quot;DejaVu Sans Mono&quot;</span>
<span style="color: #666666; font-style: italic;">#font=&quot;Bitstream Vera Sans Mono&quot;</span>
<span style="color: #666666; font-style: italic;">#font=&quot;luxi mono&quot;</span>
<span style="color: #666666; font-style: italic;">#font=&quot;Andale Mono&quot;</span>
<span style="color: #666666; font-style: italic;">#font=&quot;courier&quot;</span>
<span style="color: #007800;">font_size</span>=<span style="color: #000000;">12</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exec</span> xterm <span style="color: #660033;">-bg</span> black <span style="color: #660033;">-fg</span> white \
    <span style="color: #660033;">-fa</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$font</span>&quot;</span> \
    <span style="color: #660033;">-fd</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$font</span>&quot;</span> \
    <span style="color: #660033;">-fs</span> <span style="color: #007800;">$font_size</span> \
    <span style="color: #660033;">-j</span> <span style="color: #660033;">-s</span> \
    <span style="color: #660033;">-sb</span> <span style="color: #660033;">-si</span> <span style="color: #660033;">-sk</span> <span style="color: #660033;">-vb</span> <span style="color: #660033;">-sl</span> <span style="color: #000000;">1024</span> <span style="color: #660033;">-rightbar</span> \
    +sf +<span style="color: #c20cb9; font-weight: bold;">dc</span> <span style="color: #660033;">-cr</span> darkgreen  \
    <span style="color: #660033;">-u8</span> <span style="color: #660033;">-geometry</span> 100x40 \
    $<span style="color: #000000; font-weight: bold;">@</span> <span style="color: #000000; font-weight: bold;">&amp;</span> 
<span style="color: #7a0874; font-weight: bold;">exit</span></pre></div></div>

<p>The important options here are <b>-u8</b>, <b>-fa</b> and <b>-fd</b>.   This would be perfect, except that I can&#8217;t find a good mono-spaced TrueType font that has all of the character sets.  More on that in the font section.</p>
<p>If you want support for all character sets, you can use the &#8220;fixed&#8221; font built in to X, which has a very<br />
complete character set.  I use this script inspired by <a href="http://www.maruko.ca/i18n/">Marjan Parsa</a> instead :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exec</span> xterm <span style="color: #660033;">-bg</span> black <span style="color: #660033;">-fg</span> white \
    <span style="color: #660033;">-j</span> <span style="color: #660033;">-s</span> \
    <span style="color: #660033;">-sb</span> <span style="color: #660033;">-si</span> <span style="color: #660033;">-sk</span> <span style="color: #660033;">-vb</span> <span style="color: #660033;">-sl</span> <span style="color: #000000;">1024</span> <span style="color: #660033;">-rightbar</span> \
    +sf +<span style="color: #c20cb9; font-weight: bold;">dc</span> <span style="color: #660033;">-cr</span> darkgreen  \
    <span style="color: #660033;">-u8</span> <span style="color: #660033;">-geometry</span> 100x40 \
    <span style="color: #660033;">-xrm</span> <span style="color: #ff0000;">&quot;xterm*font:-misc-fixed-medium-r-normal--18-120-100-100-c-90-iso10646-1&quot;</span>  \
    <span style="color: #660033;">-xrm</span> <span style="color: #ff0000;">&quot;xterm*wideFont:-misc-fixed-medium-r-normal-ja-18-120-100-100-c-180-iso10646-1&quot;</span>  \
    $<span style="color: #000000; font-weight: bold;">@</span> <span style="color: #000000; font-weight: bold;">&amp;</span> 
<span style="color: #7a0874; font-weight: bold;">exit</span></pre></div></div>

<h2>Fonts</h2>
<p>You have two choices here : Fixed fonts and TrueType fonts.    In my experience, the TrueType fonts look better, and the Fixed fonts have more characters supported.</p>
<h3>TrueType</h3>
<p>I can&#8217;t seem to find a perfect TrueType &#8220;Console&#8221; font that is fixed-width, looks great, and supports all the Unicode (UTF-8) character sets like Europe, Hebrew, Japanese, Chinese, etc.    So I compromise the character set support and just get the pretty one.   So far I am most happy with Microsoft&#8217;s &#8220;Consolas&#8221;.  Yes, Microsoft!</p>
<p>Here are some good ones to check out:</p>
<ul>
<li><a href="http://www.microsoft.com/downloads/details.aspx?familyid=22e69ae4-7e40-4807-8a86-b3d36fab68d3&#038;displaylang=en">Consolas</a>
</li>
<li><a href="http://dejavu-fonts.org/wiki/index.php?title=Download">DejaVu Sans Mono</a>
</li>
<li>luxi mono
</li>
</ul>
<p>If you would like to add TrueType fonts to your account / home directory locally, just create a ~/.fonts directory and then copy the .ttf fonts into it.   Try these command to explore what fonts you have :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">fc-list                 <span style="color: #666666; font-style: italic;">#  see what fonts are loaded.</span>
xfd <span style="color: #660033;">-fa</span> <span style="color: #ff0000;">&quot;DejaVu Sans Mono&quot;</span>  <span style="color: #666666; font-style: italic;">#  explore a certain font</span></pre></div></div>

<h3>Fixed / System Fonts</h3>
<p>I use the following two options when launching Xterm to specify the system fonts :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #660033;">-xrm</span> <span style="color: #ff0000;">&quot;xterm*font:-misc-fixed-medium-r-normal--18-120-100-100-c-90-iso10646-1&quot;</span>
<span style="color: #660033;">-xrm</span> <span style="color: #ff0000;">&quot;xterm*wideFont:-misc-fixed-medium-r-normal-ja-18-120-100-100-c-180-iso10646-1&quot;</span></pre></div></div>

<p>Try these commands to see what UTF-8 fonts you have and what&#8217;s in them :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">xlsfonts <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #000000;">10646</span>
xfd <span style="color: #660033;">-fn</span> <span style="color: #ff0000;">&quot;-ibm-courier-medium-r-normal--0-0-0-0-m-0-iso10646-1&quot;</span></pre></div></div>

<p>This is the settings / fonts I used for the above screen shot.  See also this <a href="http://www.yolinux.com/TUTORIALS/LinuxListOfFonts.html">Linux Font Tutorial</a>.</p>
<h2>Shell / Environment Variables</h2>
<p>Key to all of this is that you have your LANG environment variable set correctly</p>
<p>Edit ~/.bashrc and make sure this line is happening :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">LANG</span>=en_US.utf8</pre></div></div>

<p>Remember, you will need this on two machines : the machine you are creating the X-Term window on, and the machine that you are launching mutt on.  These may be the same machine, maybe not.</p>
<p>To get a list of the locales available use this command :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">locale <span style="color: #660033;">-a</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-i</span> utf</pre></div></div>

<p>Note that these are case-sensitive, so if you have it set to <b>en_US.UTF8</b> instead of <b>en_US.utf8</b> you will get some wanky errors.</p>
<h2>Mutt</h2>
<p>Mutt works pretty well out of the box w/ UTF8.   For reference see <a href="http://wiki.mutt.org/?MuttFaq/Charset">The Mutt FAQ</a>.</p>
<p>I used these options in my .muttrc:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">set</span> allow_8bit
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">allow_ansi</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span>                  <span style="color: #666666; font-style: italic;"># in msgs</span>
charset-hook us-ascii iso-<span style="color: #000000;">8859</span>-<span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">send_charset</span>=<span style="color: #ff0000;">&quot;us-ascii:iso-8859-1&quot;</span></pre></div></div>

<p>So what this is doing is still using UTF-8 as my LANG setting and encoding for the terminal, but it&#8217;s sending my messages out as iso-8859-1.   It also is assuming that anything that comes in as &#8220;us-ascii&#8221; is actually iso-8859-1.</p>
]]></content:encoded>
			<wfw:commentRss>http://warped.org/blog/2009/06/08/getting-accents-utf8-in-mutt-using-xterm-with-truetype/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

