<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Acko.net]]></title>
  <link href="https://acko.net/atom.xml" rel="self"/>
  <link href="https://acko.net/"/>
  <updated>2026-03-05T12:10:39+01:00</updated>
  <id>https://acko.net</id>
  <author>
    <name><![CDATA[Steven Wittens]]></name>
    
  </author>

  
  <entry>
    <title type="html"><![CDATA[Proposal for Implementing Unicode in PHP]]></title>
    <link href="https://acko.net/blog/proposal-for-implementing-unicode-in-php/"/>
    <updated>2005-06-03T00:00:00+02:00</updated>
    <id>https://acko.net/blog/proposal-for-implementing-unicode-in-php</id>
    <content type="html"><![CDATA[<div class="g8 i2 first"><div class="pad">
  
<p>On the <a href="http://www.drupal.org/">Drupal team</a>, I am known as an <em>encoding nut</em>: whenever there's an encoding issue or a question about Unicode, people tend to knock on my door. Usually any fix or answer from me is accompanied by a lot of cursing to the unfortunate inquirer about how "PHP is horrible when it comes to string handling" and how it seems that "the entire PHP dev team has its head planted firmly into the ground when it comes to Unicode".
</p>

<p>
To which the reply is more than often: "Why don't you fix it yourself?".
</p>

<p>
Well, I'm not a PHP language developer. To be honest I have no interest or time for becoming one. But I do know a lot about encodings and Unicode, so I decided to write this article describing the problem and possible solutions. That way, maybe others can take some of these ideas and put them into practice. At the very least, it should answer a lot of questions that people have about Unicode and PHP.
</p>

<p>
Right now, the message from the PHP developers seems to be that "PHP supports Unicode, but some assembly is required". In fact, it is a lot worse. Please, read on.
</p>

<h2><span>About encodings and Unicode</span></h2>

<p>
First, I recommend that anyone reading this article first reads <a href="http://www.joelonsoftware.com/articles/Unicode.html">The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)</a> by Joel Spolsky. It is an excellent introduction to Unicode and encodings in general. Note also that the article was written in 2003 and specifically mentions PHP's Unicode support being hopeless. We are now two years later and the situation has not changed much.
</p>

<p>
The only important thing about Unicode which isn't explained in Joel's article is that Unicode is in fact more than just a big table which maps characters to numbers: it is also a set of character properties, recommendations and algorithms on how those characters should be used. And this is why Unicode needs (and deserves!) much more attention than any other character set.
</p>

<h2><span>What is the current situation?</span></h2>

<p>
As far as PHP is concerned at the moment, a character consists of 8 bits and a string is a series of characters. This is good enough for legacy 8-bit encodings (like the common ISO-8859-1 or Latin-1 encoding used in Western Europe), but does not cater to more complicated encodings.
</p>

<p>
To accomodate those, the <a href="http://php.belnet.be/mbstring">multibyte string extension</a> (Mbstring) can be used. This extension was originally developed for handling Japanese encodings, but it has now been extended to support many more encodings, including the Unicode Transformation Formats (like the popular UTF-8). Mbstring provides encoding-aware versions of many of PHP's string functions (<code>substr()</code>, <code>strlen()</code>, <code>ereg()</code>, ...). Through a feature called overloading, you can tell PHP to always use the Mbstring version of a function if there is one.
</p>

<p>
Aside from Mbstring, there are a few other libraries and extensions which may be used to provide encoding- and Unicode-related services, like Imap, Iconv or GNU Recode.
</p>

<h2 id="mbstring-sucks"><span>What problems are there with the current approach?</span></h2>

<ol>
<li>
<p><strong>PHP itself still doesn't know anything about encodings or Unicode.</strong>
Aside from function calls, there are other ways of interacting with strings in PHP. For example, there is the <code>{}</code> operator for selecting characters from strings, as if they were arrays. And like in most programming languages, you can define strings in code with the familiar quote syntax. But all of these methods work with literal bytes, not with actual encoded characters.
</p>

<p>
PHP source code itself must be encoded in an ASCII-compatible encoding and there is no way to use Unicode codepoints directly. If you want to store a character in a variable, you either have to use a short string of bytes (the encoded representation of the character) or an integer representing the character's Unicode codepoint. But converting between a codepoint and its encoded representation requires ugly work-arounds and wrappers, as PHP itself provides no easy mechanism for doing this.
</p></li>


<li><p><strong>PHP does not guarantee anything about the local setup as far as encoding support goes.</strong>
All the actual encoding functionality is located in libraries or extensions which may not be present on the average PHP install or which may be outdated. This makes it very difficult to make Unicode-compatible PHP programs work everywhere. One of PHP's assets is its large install base, yet the large majority of those installs is completely unsuited for Unicode work. At the time of writing this article, the latest PHP (5.0.4) still does not enable the Mbstring extension by default.
</p>

<p>
A trickier example: in Drupal 4.6.0 we depend on the Perl-compatible Regular Expression Library's support for Unicode and UTF-8. This was <a href="http://php.belnet.be/manual/en/reference.pcre.pattern.modifiers.php">supposedly present</a> since PHP 4.1 (exception: since PHP 4.2.3 on Windows). But actual testing shows that it took until PHP 4.3.3 for this library to know how to deal correctly with UTF-8 and the full Unicode range. But even now, PHP still has the ability to use the system-provided PCRE library, which can still be compiled without UTF-8 support. This can result in unsupported installs even for those using the latest PHP version.
</p>
</li>


<li><p><strong>When you use Mbstring overloading, you can no longer easily work with strings of binary data.</strong>
Mbstring overloading sounds nice in theory, as it gives you smarter string functions for free without having to adapt your code. However, this feature denies a basic fact: <em>text strings are fundamentally different from binary data</em>. If this sounds strange to you, consider this:
</p>

 <ul>
  <li>Binary data requires no meta-information about its encoding and can be passed around freely. Operations on two byte arrays are guaranteed to work. Text, on the other hand, is always encoded in a particular way. Text operations can only work if the encoding is known and verified to be the same for all operands involved.</li>
  <li>Binary data can contain arbitrary bits, while most text encodings have a much more limited syntax. Take a look at <a href="http://php.belnet.be/utf8_encode">UTF-8's bit patterns</a> for example. However, even plain US-ASCII text has historically had the limitation that it may not contain the NULL character.</li>
  <li>Binary data has no intrinsic semantic meaning, while text does. Many operations (like case conversion) only make sense on text, while other operations become much more complicated (e.g. text sorting needs to take local conventions into account). Specifically, there are a lot of Unicode algorithms for advanced text processing (e.g. the Bidirectional Algorithm for handling text with mixed writing directions).</li>
 </ul>

<p>
Due to the fact that text has been 8-bit encoded for a long time, a lot of programmers don't think twice about using text functions for dealing with binary data and vice-versa. But this assumption is no longer valid today.
</p>

<p>
If Mbstring overloading is enabled and a PHP programmer wants to perform operations on binary data, (s)he has to temporarily trick PHP into using a simple 8-bit encoding (like ISO-8859-1). Quite possibly, locale settings have to be changed back and forth as well. This results in bloated, complicated code.
</p>
</li>


<li><p><strong>PHP's string functions don't form a clean, consistent API.</strong>
There is no consistent naming convention (e.g. <code>substr()</code>, <code>str_replace()</code>, <code>convert_cyr_string()</code>, <code>parse_str()</code>, <code>sprintf()</code>, ...).
</p>

<p>
There are also a bunch of hodge-podge functions which are only useful in very specific situations and/or which are tied to a particular encoding (e.g. <code>utf8_encode()</code>) or locale (e.g. <code>ucfirst()</code>).
</p>

<p>
Finally, though some functions take an encoding argument to allow for some encoding support, this is rare and inconsistent. For example, while the <code>html_entities()</code> function supports several encodings, the utility function <code>get_html_translation_table()</code> which fetches its translation table does not.
</p>
</li>


<li><p><strong>PHP's locale mechanism is completely platform-dependant and offers no guarantees.</strong>
The locale identifiers passed to <code>setlocale()</code> <a href="http://php.belnet.be/set_locale">differ completely</a> between Windows and Unix platforms, but even between similar Unix platforms there is no guarantee of which locales are available. The dependency of PHP on system locales also means that you are restricted to whatever encodings the system locales are available in.
</p>
</li>


<li><p><strong>PHP's XML parser is notorious for violating the specifications when it comes to encodings.</strong>
In today's web, XML is everywhere in the form of XHTML, RSS feeds, OPML, etc. Being able to parse XML correctly is essential to any PHP application. A significant portion of the XML specification talks about encodings and how to deal with them, but PHP does not implement them correctly.
</p>

<p>
For example, if an XML document starts with a UTF-8 signature (in the form of the byte-order mark), PHP5's parser will die if it is told the document is in UTF-8 encoding. Similar simple, but critical bugs have had to be worked around by PHP programmers in the past. Before PHP5, absolutely no encoding autodetection was present in the XML parser: this had to be done by the code invoking the parser.
</p>
</li>


<li><p><strong>Mbstring is a pragmatic library, not a fully featured Unicode solution</strong>.
Example limitations include not being able to specify characters beyond U+FFFF for some functions (e.g. <code>mb_substitute_character()</code>) or the way <code>mb_strwidth()</code> seems to be <a href="http://be.php.net/manual/en/function.mb-strwidth.php">hardcoded for Japanese only</a> (there are no zero widths for combining accents?).</p></li>
</ol>

<p>
All of these problems together mean that it is very hard at the moment to write PHP software which can support encodings and Unicode. Even worse, if this software has to run on a typical PHP install, then you can forget about implementing anything more than simple pass-through behaviour as far as text is concerned.
</p>

<h2><span>Proposed solution</span></h2>

<p>
Unfortunately, PHP is very hot on backwards compatibility, so significant changes to the existing string API are pretty much out of the question. New types and APIs need to be introduced which offer a complete, consistent and flexible solution for dealing with encodings and Unicode.
</p>


<ol>
<li><p><strong>PHP needs a new Unicode text string type which is separate from the classic byte string.</strong>
This type, let's call it <em>ustring</em>, would represent a string of Unicode text.
</p>

<p>
Internally, it would be stored using one of the UTF's. In the interests of internal processing efficiency, UTF-16 is probably the best choice, but UTF-8 can be considered as well as it is the most popular UTF on the web today. In that case, outputting UTF-8 could be done without any conversion. On the other hand, the complicated bit patterns and variability of UTF-8 mean that it is harder to find character boundaries and such. Looking at how languages like Perl and Python approach this is a good idea. After all, they've had Unicode strings for quite some time.
</p>

<p>
To distinguish <em>ustrings</em> from plain strings when defined, a syntax similar to C could be introduced, for example <code>U&quot;This&nbsp;is&nbsp;a&nbsp;Unicode&nbsp;string&quot;</code>. This syntax would support <code>\u####</code>, <code>\U########</code> and <code>\x{#..}</code> notation for defining characters by codepoint inside the string.
</p>

<p>
Using the <code>{}</code> operator on a <em>ustring</em> would return ints, not chars. To reduce confusion, perhaps a <em>uchar</em> type could be introduced specifically for handling Unicode codepoints. As the Unicode codespace is only 21-bit wide, there would be subtle differences between <em>uchar</em> and <em>int</em>, though both would probably be stored as 32-bit.
</p>

<p>
For backwards compatibility, plain quoted strings would remain used for byte strings, although it might be interesting to define a <code>B&quot;This&nbsp;is&nbsp;a&nbsp;byte&nbsp;string&quot;</code> notation, while providing a configurable option for choosing which type of string is assumed when there is no prefix. As Unicode usage would become more widespread, it would be nice to not have to litter your code with U's everywhere.
</p>

<p>
Though the internal encoding would be fixed to one of the UTF's, the external encoding might vary (and would be configurable through an API). When casting a <em>ustring</em> to a <em>string</em>, a conversion would take place from the internal encoding to the external one, and vice-versa. It remains to be seen which type takes precedence when both are mixed together (e.g. <code>$string&nbsp;=&nbsp;U&quot;Unicode&quot;&nbsp;.&nbsp;&quot;Bytes&quot;</code>).
</p>
</li>


<li><p><strong>PHP needs a new Unicode string API.</strong>
This API would contain a selection of functions from both the plain String API as well as the Mbstring API, but would have a simpler and more logical naming convention. For example, making all ustring functions start with <code>ustr_</code>. Each of these would accept a <em>ustring</em> where the current ones accept a plain <em>string</em>.
</p>

<p>
External APIs, like the PCRE library, could choose whether to accept <em>string</em>, <em>ustring</em> or both. For example for PCRE, it makes sense to replace the PHP-proprietary <code>/u</code> modifier with a simple string type check instead.
</p>
</li>


<li><p><strong>PHP needs to ensure that a baseline set of encoding-related functions are always available.</strong>
I believe the Iconv extension is now standard since PHP5, but things like complete UTF-8 support in PCRE are important too. This allows programmers to write their code in a straightforward fashion without having to check for a gazillion exceptions or exotic configurations.
</p>
</li>

<li><p><strong>PHP needs an independent locale library across all platforms</strong>
This ensures consistent handling of locales and no longer limits PHP to what the platform supports. The <a href="http://www-306.ibm.com/software/globalization/icu/index.jsp">International Components for Unicode</a> (ICU) are an excellent candidate.</p>
</li>
</ol>


<p>
The choice to limit this new string functionality to Unicode strings might seem elitist: after all, the idea of Unicode is <em>not</em> to get rid of other encodings, but merely to ensure compatibility. Non-Unicode encodings will keep fulfilling an important role in the years to come. On the other hand, as Unicode is guaranteed to be a perfect intermediate format, it makes sense to use it for internal string handling. It limits the functionality that has to be dealt with and creates a common baseline to work with.
</p>

<p>
Finally, as the original String and Mbstring APIs would not be altered by these changes, programmers would be free to use the 'old school' way of dealing with strings. They would simply not be able to take advantage of the cleaner API and consistent locales.
</p>

</div></div>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[PHP, Unicode and ostriches.]]></title>
    <link href="https://acko.net/blog/php-unicode-and-ostriches/"/>
    <updated>2005-03-25T00:00:00+01:00</updated>
    <id>https://acko.net/blog/php-unicode-and-ostriches</id>
    <content type="html"><![CDATA[<div class="g8 i2 first"><div class="pad"><p><em>Update: I've written a <a href="/blog/unicode-in-php">follow-up post</a> that describes how I would like PHP's encoding support to be.</em>
</p>

<p>
As the resident encoding geek on the <a href="http://www.drupal.org/">Drupal</a> team, it's usually my job to make sure Drupal handles encodings and Unicode correctly. I don't mind doing this, but PHP doesn't exactly make it easy. With the new search.module for Drupal 4.6 being Unicode-aware, this has become very obvious, as we've had to bump up the minimum required version of PHP to 4.3.3. The UTF-8 support in the Perl-compatible regular expressions in PHP 4.3.2 and earlier is completely broken. And now I've had a bug report about someone on PHP 4.3.8 who still had problems getting it to work.
</p>

<p>
I don't know why exactly, but as far as encodings go PHP is still in the stone-age. This is odd, as you'd expect a web-oriented scripting language to have excellent support for sharing and exchanging textual information. There is a multi-byte string extension available, but it's not available on 90% of PHP hosts out there, and it's more of a black-box library anyway: it does not present you your strings as Unicode character codepoints, but still as an array of bytes. Furthermore, if you actually enable the mbstring overrides, you lose the ability to work with bytes at will. Apparently, the PHP team still hasn't figured out that bytes and characters are not the same. The other extensions which deal with encodings (iconv, recode) are also unavailable on the majority of PHP installs out there.
</p>

<p>
This means that if you want to make a PHP application which supports any language <em>and</em> runs on the average PHP host out there, that there's only one option: use UTF-8 internally, and write your own functions for string truncation, email header encoding, validation, etc. Using UTF-8 ensures that you only have one encoding to worry about and because it's Unicode it is guaranteed to be able to represent any language. Of course, you will no longer be able to do something simple as upper/lowercasing a string, as these PHP functions don't take UTF-8 at all.
</p>

<p>
What PHP needs is Unicode string support in the core, along with a good library of useful functions for handling the very large Unicode character range efficiently. ASP, Perl, Python, Java all have it... for me, it's the only thing that would've made PHP5 worth to upgrade to.
</p>

<p>
It's as if the entire PHP team has stuck their head in the ground, hoping that all this Unicode stuff will somehow blow over. It won't.
</p></div></div>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Sprankle Character Map]]></title>
    <link href="https://acko.net/blog/sprankle-character-map/"/>
    <updated>2004-12-23T00:00:00+01:00</updated>
    <id>https://acko.net/blog/sprankle-character-map</id>
    <content type="html"><![CDATA[<div class="g8 i2 first"><div class="pad"><p>It hit me a while ago that entering characters which are not available on your keyboard or through your <acronym title="Input Method Editor">IME</acronym> is much too complicated. Usually it involves opening up some character map, scrolling through hundreds of symbols to find the one you need and copy/pasting it into the application of your choice.
</p>

<p>
Not very handy. Enter <em>Sprankle Character Map</em>. The idea is to hit a special key combination when typing (WIN + S for Sprankle) which pops up a character map where you are typing. You then type a symbol to find similar characters and choose one from the list using either numbers or arrows + space. Here's how it looks.
</p>

<p>
<img class="natural" src="/files/sprankle/sprankle.png" alt="Sprankle Character Map" />
</p>

<p>
This is just a prototype, but it demonstrates the idea nicely and it's actually pretty usable. Certainly better than firing up a full character map every time.
</p>

<p>
Notes:
<ul><li>Sprankle is a Unicode-application and only runs on Windows 2000/XP.</li>
<li>The map appears on top of the current text field. For large, multi-line text fields this is far from ideal. It would be better to have it appear at the current caret position.</li>
<li>Sprankle doesn't work on Mozilla Firefox (or other applications that do special keyboard processing). If anyone has an idea on how to fix this, please tell.</li>
<li>It might be better to implement Sprankle as a real <acronym title="Input Method Editor">IME</acronym> so it integrates completely with the text field. I have no idea how to do this though, but I'm sure MSDN has some documentation about it. The downside would be that it might not work in combination with existing IMEs (e.g. for Japanese).</li>
<li>Many of the symbols in the character set are not present in most fonts. Sprankle currently looks for Arial Unicode MS, the universal font that comes with XP and Office.</li>
<li>It might be cool to make a JavaScript version of this, so it can be integrated on websites with CMSes like <a href="http://www.drupal.org/">Drupal</a>.</li>
<li>You can customize Sprankle's character sets by editing <code>sprankle.txt</code> (UTF-16LE encoded). Right now it covers most of the Latin characters, basic Greek plus some math symbols.</li>
</ul>
</p>

<p>
<a href="/files/sprankle/sprankle.zip">Download Sprankle</a> (source + win32 binary).
</p>

<p>
<img class="natural" src="/files/sprankle/sprankle-ex.png" alt="Example of Sprankle Character Map" />
</p></div></div>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[UFPDF: Unicode/UTF-8 extension for FPDF]]></title>
    <link href="https://acko.net/blog/ufpdf-unicode-utf-8-extension-for-fpdf/"/>
    <updated>2004-09-01T00:00:00+02:00</updated>
    <id>https://acko.net/blog/ufpdf-unicode-utf-8-extension-for-fpdf</id>
    <content type="html"><![CDATA[<div class="g8 i2 first"><div class="pad"><p><b>Note: I wrote UFPDF as an experiment, not as a finished product. If you have problems using it, don't bug me for support. Patches are welcome though, but I don't have much time to maintain this.</b>
</p>

<p>
<a href="http://www.fpdf.org">FPDF</a> is a PHP class for generating PDF files on-the-fly. Unfortunately it does not support Unicode. So I've coded UFPDF, an extension of FPDF which accepts input in UTF-8.
</p>

<p>
Only TrueType fonts are supported for now. To embed .TTF files, you need to extract the font metrics and build the required tables using the provided utilities (see README.txt). Included is a modified version of <a href="http://ttf2pt1.sourceforge.net/">TTF2PT1</a> which extracts the Unicode glyph info.
</p>

<p>
UFPDF works the same as FPDF, except that all text is in UTF-8, so consult the <a href="http://www.fpdf.org/en/doc/index.php">FPDF documentation</a> for usage.
</p>

<p>
<a href="https://acko.net/files/ufpdf/ufpdf.zip">Download UFPDF</a>
<a href="https://acko.net/files/ufpdf/unicode.pdf">Example PDF</a></p></div></div>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[UTF-8 conversion support for mIRC]]></title>
    <link href="https://acko.net/blog/utf-8-conversion-support-for-mirc/"/>
    <updated>2004-07-13T00:00:00+02:00</updated>
    <id>https://acko.net/blog/utf-8-conversion-support-for-mirc</id>
    <content type="html"><![CDATA[<div class="g8 i2 first"><div class="pad"><p><a href="http://www.mirc.com">mIRC</a>'s lack of UTF-8 support has been an issue for quite some time. The author promised to 'look at it', but in the meantime, chatting in UTF-8 is not possible. This is problematic for any language that uses more than the occasional accented letter.</p>

<p>So I decided to make a temporary fix myself. The result is a flexible conversion mechanism between UTF-8 and the ANSI codepages. The user sees and types regular ANSI characters, but all data which is sent to and received from the IRC server is UTF-8 encoded. You are still limited to one ANSI codepage though: making mIRC support real Unicode is not possible without an mIRC rewrite.</p>
<p>The script performs a real UTF-8 encoding/decoding, so unlike a simple 'find and replace' approach, characters which do not fit into the current codepage are indicated as such.</p>

<p>I included conversion tables for all of the Windows ANSI codepages:</p>
<ul>
<li>1250 (ANSI - Central Europe)</li>
<li>1251 (ANSI - Cyrillic)</li>
<li>1252 (ANSI - Western Europe / Latin I)</li>
<li>1253 (ANSI - Greek)</li>
<li>1254 (ANSI - Turkish)</li>
<li>1255 (ANSI - Hebrew)</li>
<li>1256 (ANSI - Arabic)</li>
<li>1257 (ANSI - Baltic)</li>
<li>1258 (ANSI/OEM - Viet Nam)</li>
</ul>
<p>There is also a little utility (with source) for generating conversion tables for more codepages.</p>

<p>For instructions on how to use it, check the top of the <code>utf-8.mrc</code> file. You can <a href="/files/mirc-utf8/mirc-utf8.zip">download the script here</a> (19 KB).</p>

<p><b>Important: This script is provided as-is without any guarantees. Use it if you like it, but don't bug me if you can't get it to work. If you find bugs, feel free to report them, but try to give a little more information than just 'it doesn't work'.</b></p>

</div></div>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[My ideal text editor]]></title>
    <link href="https://acko.net/blog/my-ideal-text-editor/"/>
    <updated>2004-02-19T00:00:00+01:00</updated>
    <id>https://acko.net/blog/my-ideal-text-editor</id>
    <content type="html"><![CDATA[<div class="g8 i2 first"><div class="pad">
  
<p>Out of recommendation from a certain <a href="http://www.natrak.net/">evil norwegian</a>, I gave <a href="http://www.editpadpro.com/">EditPad Pro</a> a whirl. Took me 10 minutes to remove it again.</p>

<p>Am I too picky? Maybe. Here's what I want from a text-editor (in no particular order):</p>
<ul>
<li><strong>Runs on Windows 2000</strong>. Vent your anti-Microsoft anger somewhere else, I use Windows every day and I'm not likely to switch any time soon.</li>
<li><strong>Native Unicode and <acronym title="Unicode Transformation Format">UTF</acronym>-8 support</strong>. This is 2004. Unicode has been around for ages, and I see no reason why I should occupy myself with encoding issues. I deal with multiple languages, so Unicode is the only logical choice. Unicode compatibility is no longer a problem thanks to the Microsoft Layer for Unicode (from now on I will shoot everyone who refers to a byte as a 'character'). Note: automatic conversion between Unicode and the current ANSI codepage doesn't cut it (that's what Editpad Pro seems to do).</li>
<li><strong><acronym title="Input Method Editor">IME</acronym>-friendly</strong>, with bonus points for an integrated IME. Sometimes I type Japanese, and it requires indirect input and conversion of typed characters. Certain editors I've encountered do weird things which prevents the IME from doing its job, so that's why I mention it explicitly.</li>
<li><strong>Advanced editing for web-development</strong>. I do a lot of HTML, CSS, PHP, SQL and JavaScript, so anything that can make coding easier is a plus. The least I want is syntax highlighting, but intelligent auto-completion, validation, previewing and other visual cues are very handy too.</li>
<li><strong>Good user-interface</strong>. This one shouldn't really be necessary to mention, but so many programs seem to miss the point here: a program should be easy to use. I'm not going to go down to specifics, there are a lot of good references on the subject around. Because I'm picky as hell, reconfigurable toolbars, panels and hotkeys score good too. Don't confuse this item with the next one, which is:</li>
<li><strong>Nice to look at</strong>. I don't need menus that whiz by, flashy windows with skins or other novelty visual effects, but that doesn't mean my applications can be butt-ugly. Things such as proper spacing and margins, aesthetic proportions and contemporary looks are big pluses.</li>
</ul>

<p>I don't think these are such crazy demands, so if anyone who has suffered through this rant up to now knows a program which satisfies these conditions, please post a link here ;).</p>

<p><b>Update</b>: I've settled for <a href="http://www.flos-freeware.ch/notepad2.html">Notepad2</a> for now. It's a small, functional, neat editor and it's open-source too.</p>

</div></div>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Drupal XML weirdness]]></title>
    <link href="https://acko.net/blog/drupal-xml-weirdness/"/>
    <updated>2003-12-14T00:00:00+01:00</updated>
    <id>https://acko.net/blog/drupal-xml-weirdness</id>
    <content type="html"><![CDATA[<div class="g8 i2 first">
  <div class="pad">
    <p>So I was looking at <a href="http://www.drupal.org/import">Drupal's import page</a> and noticed non-ascii characters looked quite botched. Some source viewing revealed the input had apparently been utf8 encoded twice (that is UTF'd, then assumed to be ISO-8859-1 and UTF'd again).</p>
    <p>The source was <a href="http://feedster.com/rss.php?q=Drupal&amp;sort=date&amp;ie=UTF-8">an XML feed in UTF8</a> which looked perfectly fine. I went over <code>import.module</code> and couldn't see any specific UTF8 encoding. Some testing revealed that PHP's XML parser was the culprit:</p>
    <p class="codeblock"><code>&lt;?php<br />
      $xmlfile = "&lt;?xml version=\"1.0\" encoding=\"utf-8\" ?&gt;&lt;tag&gt;UTF8 v\xC3\xA3lue&lt;/tag&gt;";<br />
      <br />
      function handler_data($parser, $data) {<br />
      &nbsp;&nbsp;print "Data: $data\r\n";<br />
      }<br />
      <br />
      $xml_parser = xml_parser_create();<br />
      xml_set_character_data_handler($xml_parser, "handler_data");<br />
      xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, "utf-8");<br />
      xml_parse($xml_parser, $xmlfile, 1);<br />
      xml_parser_free($xml_parser);<br />
      ?&gt;
      </code>
    </p>
    <p>
      The input XML contains the word <i>vãlue</i> and is in UTF8 format. The output encoding is specified as UTF8 as well, so you would expect PHP to print out the value unchanged (i.e. with 2 bytes for the <i>ã</i> character). Not so... PHP incorrectly treats the input as ISO-8859-1 and re-UTF's the input, resulting in 4 bytes for the <i>ã</i> character.
    </p>
    <p>This is strange because PHP <a href="http://be2.php.net/manual/nl/ref.xml.php#xml.encoding">claims to support UTF-8 source encoding</a>.</p>
  </div>
</div>
]]></content>
  </entry>
  
</feed>
