<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>This site works best in a real browser - Coding</title>
    <link>http://grahamcox.co.uk/serendipity/</link>
    <description>My little place on the web...</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.5.3 - http://www.s9y.org/</generator>
    <pubDate>Tue, 17 Aug 2010 10:10:26 GMT</pubDate>

    <image>
        <url>http://grahamcox.co.uk/serendipity/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: This site works best in a real browser - Coding - My little place on the web...</title>
        <link>http://grahamcox.co.uk/serendipity/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Calling Maven2 from Ant</title>
    <link>http://grahamcox.co.uk/serendipity/index.php?/archives/39-Calling-Maven2-from-Ant.html</link>
            <category>Code Snippets</category>
    
    <comments>http://grahamcox.co.uk/serendipity/index.php?/archives/39-Calling-Maven2-from-Ant.html#comments</comments>
    <wfw:comment>http://grahamcox.co.uk/serendipity/wfwcomment.php?cid=39</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://grahamcox.co.uk/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=39</wfw:commentRss>
    

    <author>nospam@example.com (Graham Cox)</author>
    <content:encoded>
    There is a lot of information available on how to call Ant from Maven2 scripts, but very little on the reverse operation. As it happens, this is actually quite simple to manage - Maven2 is a Java app, so it can be executed by simply using the Java task from inside your Ant script with the correct classpath, Main class name and arguments. The following snippit will do this for the simple case:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;target&amp;#160;name=&quot;execute_maven&quot;&amp;#62;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;java&amp;#160;classname=&quot;org.codehaus.classworlds.Launcher&quot;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;fork=&quot;yes&quot;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;failonerror=&quot;true&quot;&amp;#62;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;arg&amp;#160;value=&quot;${maven.target}&quot;&amp;#160;/&amp;#62;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;sysproperty&amp;#160;key=&quot;classworlds.conf&quot;&amp;#160;value=&quot;${maven.home}/bin/m2.conf&quot;&amp;#160;/&amp;#62;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;sysproperty&amp;#160;key=&quot;maven.home&quot;&amp;#160;value=&quot;${maven.home}&quot;&amp;#160;/&amp;#62;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;classpath&amp;#62;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;pathelement&amp;#160;location=&quot;${maven.home}/boot/classworlds-1.1.jar&quot;&amp;#160;/&amp;#62;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;/classpath&amp;#62;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;/java&amp;#62;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;/target&amp;#62;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Note that this depends on the property &quot;maven.home&quot; being set correctly, and when called it will require the &quot;maven.target&quot; parameter to be supplied. &quot;maven.home&quot; will likely be set in build.properties or similar, and calling it is as simple as&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;antcall&amp;#160;target=&quot;execute_maven&quot;&amp;#62;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;param&amp;#160;name=&quot;maven.target&quot;&amp;#160;value=&quot;install&quot;&amp;#160;/&amp;#62;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;/antcall&amp;#62;&lt;/div&gt; 
    </content:encoded>

    <pubDate>Tue, 17 Aug 2010 11:10:26 +0100</pubDate>
    <guid isPermaLink="false">http://grahamcox.co.uk/serendipity/index.php?/archives/39-guid.html</guid>
    
</item>
<item>
    <title>Automatic testing of the Linux Kernel</title>
    <link>http://grahamcox.co.uk/serendipity/index.php?/archives/37-Automatic-testing-of-the-Linux-Kernel.html</link>
            <category>Coding</category>
    
    <comments>http://grahamcox.co.uk/serendipity/index.php?/archives/37-Automatic-testing-of-the-Linux-Kernel.html#comments</comments>
    <wfw:comment>http://grahamcox.co.uk/serendipity/wfwcomment.php?cid=37</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://grahamcox.co.uk/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=37</wfw:commentRss>
    

    <author>nospam@example.com (Graham Cox)</author>
    <content:encoded>
    I was reading fairly recently about somebody (No attribution because I really can&#039;t remember who it was or where I read it. Sorry) who has a setup where he can do automatic bisect runs on the linux kernel by building the kernel, copying the built files across to a second machine and causing the second machine to reboot. The build was then considered bad if the second machine hadn&#039;t come up within 10 minutes, and the entire process was automatic except for needing to reboot the machine by hand if it didn&#039;t come up.&lt;br /&gt;
&lt;br /&gt;
This got me to thinking about ways that this can be improved. I haven&#039;t tested this yet, but in theory this would work just as well but be more streamlined. &lt;br /&gt;
&lt;br /&gt;
The first thought was to use a virtual machine - something like VMWare or VirtualBox - instead of a physical machine then the script can also be responsible for killing the machine if it doesn&#039;t come up. &lt;br /&gt;
&lt;br /&gt;
It then occured to me that this can be taken a step further by having a virtual machine booting off of a live CD - one that was specially crafted using the newly built kernel. This way, there&#039;s no requirement to have the machine be able to boot in order to install the new kernel. The entire process would be something like:&lt;br /&gt;
&lt;br /&gt;
** Build kernel&lt;br /&gt;
** Master a new Live CD image featuring the kernel&lt;br /&gt;
** Fire up the virtual machine using the newly mastered Live CD&lt;br /&gt;
** Test if it worked&lt;br /&gt;
** Kill the virtual machine&lt;br /&gt;
** Repeat&lt;br /&gt;
&lt;br /&gt;
Testing if it worked is a slightly tricky one - I think the article I read used a serial console to do this, but I&#039;m not sure if that&#039;s possible on a virtual machine. What is possible though is if the script was to run up a network server on a well known IP/Port - the script already knows these details and so can build it into the Live CD - and the Live CD run a program that connects to this network server during startup. It could even go so far as to make the only process that is loaded in startup - after all of the required networking stuff is loaded, obviously - be the client that connects to this server. The script can then determine success/failure by if the server gets a connection from the virtual machine within a known period of time - 10 minutes works, but can probably be cut down quite a lot since the virtual machine is doing very little now. I&#039;d like to think with the amount that is being done, a boot up time of 2 minutes is slow...&lt;br /&gt;
&lt;br /&gt;
As I said - I&#039;ve not even considered how to go about making this a reality, but it&#039;s an interesting thought that could streamline bisecting of kernels to see which ones boot with zero user intervention. 
    </content:encoded>

    <pubDate>Sat, 28 Feb 2009 11:34:10 +0000</pubDate>
    <guid isPermaLink="false">http://grahamcox.co.uk/serendipity/index.php?/archives/37-guid.html</guid>
    
</item>
<item>
    <title>CMake code to support asciidoc</title>
    <link>http://grahamcox.co.uk/serendipity/index.php?/archives/36-CMake-code-to-support-asciidoc.html</link>
            <category>CMake</category>
    
    <comments>http://grahamcox.co.uk/serendipity/index.php?/archives/36-CMake-code-to-support-asciidoc.html#comments</comments>
    <wfw:comment>http://grahamcox.co.uk/serendipity/wfwcomment.php?cid=36</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://grahamcox.co.uk/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=36</wfw:commentRss>
    

    <author>nospam@example.com (Graham Cox)</author>
    <content:encoded>
    Asciidoc is a really useful and sensible way of allowing people to write documentation, in that the plain text source code is nearly as readable as the generated output. The following is a CMake file to allow for conversion of text input files into asciidoc generated output files&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
PROJECT(Document)&lt;br /&gt;
FIND_PACKAGE(Asciidoc)&lt;br /&gt;
IF(ASCIIDOC_FOUND)&lt;br /&gt;
  FILE(GLOB _docfiles *.txt)&lt;br /&gt;
&lt;br /&gt;
  FOREACH(_file ${_docfiles})&lt;br /&gt;
    GET_FILENAME_COMPONENT(_file_we ${_file} NAME_WE)&lt;br /&gt;
    SET(_in &quot;${_file_we}&quot;)&lt;br /&gt;
    SET(_out &quot;${_file_we}.html&quot;)&lt;br /&gt;
    IF (NOT &quot;${_in}&quot; STREQUAL &quot;CMakeLists&quot;)&lt;br /&gt;
        ADD_CUSTOM_COMMAND(&lt;br /&gt;
            OUTPUT    &quot;${_out}&quot;&lt;br /&gt;
            COMMAND   ${ASCIIDOC_EXECUTABLE} -a toc -o ${_out} ${_file}&lt;br /&gt;
            DEPENDS   ${_file}&lt;br /&gt;
            COMMENT   &quot;Asciidoc ${_in}&quot;&lt;br /&gt;
        )&lt;br /&gt;
        ADD_CUSTOM_TARGET(${_in} ALL echo&lt;br /&gt;
          DEPENDS   &quot;${_out}&quot;&lt;br /&gt;
        )&lt;br /&gt;
    ENDIF (NOT &quot;${_in}&quot; STREQUAL &quot;CMakeLists&quot;)&lt;br /&gt;
&lt;br /&gt;
  ENDFOREACH(_file)&lt;br /&gt;
ENDIF(ASCIIDOC_FOUND)&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
And it needs the following FindAsciidoc.cmake file available&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
# - Find Asciidoc&lt;br /&gt;
# this module looks for asciidoc&lt;br /&gt;
#&lt;br /&gt;
#  ASCIIDOC_EXECUTABLE - the full path to asciidoc&lt;br /&gt;
#  ASCIIDOC_FOUND      - If false, don&#039;t attempt to use asciidoc.&lt;br /&gt;
&lt;br /&gt;
FIND_PROGRAM(ASCIIDOC_EXECUTABLE&lt;br /&gt;
  asciidoc&lt;br /&gt;
  )&lt;br /&gt;
&lt;br /&gt;
MARK_AS_ADVANCED(&lt;br /&gt;
  ASCIIDOC_EXECUTABLE&lt;br /&gt;
  )&lt;br /&gt;
&lt;br /&gt;
IF (NOT ASCIIDOC_EXECUTABLE)&lt;br /&gt;
  SET(ASCIIDOC_FOUND &quot;NO&quot;)&lt;br /&gt;
ELSE (NOT ASCIIDOC_EXECUTABLE)&lt;br /&gt;
  SET(ASCIIDOC_FOUND &quot;YES&quot;)&lt;br /&gt;
ENDIF (NOT ASCIIDOC_EXECUTABLE)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
IF (NOT ASCIIDOC_FOUND AND Asciidoc_FIND_REQUIRED)&lt;br /&gt;
   MESSAGE(FATAL_ERROR &quot;Could not find asciidoc&quot;)&lt;br /&gt;
ENDIF (NOT ASCIIDOC_FOUND AND Asciidoc_FIND_REQUIRED)&lt;br /&gt;
&lt;/code&gt; 
    </content:encoded>

    <pubDate>Fri, 07 Nov 2008 13:14:38 +0000</pubDate>
    <guid isPermaLink="false">http://grahamcox.co.uk/serendipity/index.php?/archives/36-guid.html</guid>
    
</item>
<item>
    <title>Yet another IE6 Hang bug</title>
    <link>http://grahamcox.co.uk/serendipity/index.php?/archives/34-Yet-another-IE6-Hang-bug.html</link>
            <category>Web Design</category>
    
    <comments>http://grahamcox.co.uk/serendipity/index.php?/archives/34-Yet-another-IE6-Hang-bug.html#comments</comments>
    <wfw:comment>http://grahamcox.co.uk/serendipity/wfwcomment.php?cid=34</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://grahamcox.co.uk/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=34</wfw:commentRss>
    

    <author>nospam@example.com (Graham Cox)</author>
    <content:encoded>
    It appears that I have just discovered yet another IE6 hang bug- though I&#039;m probably not the first person to discover it...&lt;br /&gt;
&lt;br /&gt;
I&#039;m not sure of the exact set of circumstances that cause it to happen yet, as I&#039;ve not been able to reproduce it in a simplified form unfortunatly, but at least part of what is required is as follows:&lt;br /&gt;
&lt;ul&gt;&lt;br /&gt;
&lt;li&gt;An element - div in this case - with a margin-left of some non-zero value&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;Immediatly inside this element at least 4 input elements of type hidden, all together&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;Immediatly after these 4 input elements, an element that is defined to be float: left&lt;/li&gt;&lt;br /&gt;
&lt;/ul&gt;&lt;br /&gt;
Whether or not a doctype is present does not appear to affect the outcome, so it is not a simple reproduction of the bug mentioned at &lt;a href=&quot;http://grahamcox.co.uk/serendipity/exit.php?url=aHR0cDovL2Jsb2cuc2VhZ3VsLmNvLnVrL2FydGljbGVzLzIwMDcvMDIvMTUvY3Jhc2hpbmctaWUtNi13aXRoLXN0eWxlLXNoZWV0cw==&amp;amp;entry_id=34&quot; title=&quot;http://blog.seagul.co.uk/articles/2007/02/15/crashing-ie-6-with-style-sheets&quot;  onmouseover=&quot;window.status=&#039;http://blog.seagul.co.uk/articles/2007/02/15/crashing-ie-6-with-style-sheets&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;this blog post&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
However, the following do stop the bug from manifesting:&lt;br /&gt;
&lt;ul&gt;&lt;br /&gt;
&lt;li&gt;Making it so that there are less than 4 input elements all together before the float&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;Making at least one of the input elements to not be of type hidden&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;Putting another element between the 4 inputs and the float&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;Making the element not float any more&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;Changing the margin-left to padding-left instead.&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;Wrapping the 4 input elements in a container element themselves - This is the one I used to solve the problem, the 4 input elements now exist inside a div that is set to display: none, and everything is happy.&lt;/li&gt;&lt;br /&gt;
&lt;/ul&gt; 
    </content:encoded>

    <pubDate>Thu, 03 Jan 2008 16:10:06 +0000</pubDate>
    <guid isPermaLink="false">http://grahamcox.co.uk/serendipity/index.php?/archives/34-guid.html</guid>
    
</item>
<item>
    <title>Git ignore lists for autotools</title>
    <link>http://grahamcox.co.uk/serendipity/index.php?/archives/33-Git-ignore-lists-for-autotools.html</link>
            <category>Coding</category>
    
    <comments>http://grahamcox.co.uk/serendipity/index.php?/archives/33-Git-ignore-lists-for-autotools.html#comments</comments>
    <wfw:comment>http://grahamcox.co.uk/serendipity/wfwcomment.php?cid=33</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://grahamcox.co.uk/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=33</wfw:commentRss>
    

    <author>nospam@example.com (Graham Cox)</author>
    <content:encoded>
    Having just set up a new autotools project, and started the project in &lt;a href=&quot;http://grahamcox.co.uk/serendipity/exit.php?url=aHR0cDovL2dpdC5vci5jeg==&amp;amp;entry_id=33&quot; title=&quot;http://git.or.cz&quot;  onmouseover=&quot;window.status=&#039;http://git.or.cz&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Git&lt;/a&gt; the following is the complete .gitignore list that I&#039;ve produced to capture all of the artifacts that have been produced. This only covers the artifacts that are produced by a bare project that doesn&#039;t acutally produce any output.&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#&amp;#160;The&amp;#160;actual&amp;#160;Makefiles&amp;#160;produced&lt;br /&gt;
Makefile&lt;br /&gt;
Makefile.in&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;The&amp;#160;local&amp;#160;aclocal.m4&amp;#160;file&lt;br /&gt;
aclocal.m4&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;The&amp;#160;output&amp;#160;of&amp;#160;the&amp;#160;configure&amp;#160;script&lt;br /&gt;
config.guess&lt;br /&gt;
config.log&lt;br /&gt;
config.status&lt;br /&gt;
config.sub&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;The&amp;#160;configure&amp;#160;script&amp;#160;itself&lt;br /&gt;
configure&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;The&amp;#160;include&amp;#160;directory&amp;#160;artifacts&lt;br /&gt;
include/config.h&lt;br /&gt;
include/stamp-h1&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Various&amp;#160;scripts&amp;#160;used&amp;#160;for&amp;#160;libtool&amp;#160;and&amp;#160;the&amp;#160;like&lt;br /&gt;
install-sh&lt;br /&gt;
libtool&lt;br /&gt;
ltmain.sh&lt;br /&gt;
missing&lt;br /&gt;
depcomp&lt;br /&gt;
&lt;br /&gt;
#&amp;#160;Not&amp;#160;sure&amp;#160;what&amp;#160;this&amp;#160;one&amp;#160;is&amp;#160;for&lt;br /&gt;
autom4te.cache/&amp;#42;&lt;/div&gt; 
    </content:encoded>

    <pubDate>Tue, 04 Dec 2007 11:17:48 +0000</pubDate>
    <guid isPermaLink="false">http://grahamcox.co.uk/serendipity/index.php?/archives/33-guid.html</guid>
    
</item>
<item>
    <title>XSL in the Browser and output encodings</title>
    <link>http://grahamcox.co.uk/serendipity/index.php?/archives/32-XSL-in-the-Browser-and-output-encodings.html</link>
            <category>Coding</category>
    
    <comments>http://grahamcox.co.uk/serendipity/index.php?/archives/32-XSL-in-the-Browser-and-output-encodings.html#comments</comments>
    <wfw:comment>http://grahamcox.co.uk/serendipity/wfwcomment.php?cid=32</wfw:comment>

    <slash:comments>1</slash:comments>
    <wfw:commentRss>http://grahamcox.co.uk/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=32</wfw:commentRss>
    

    <author>nospam@example.com (Graham Cox)</author>
    <content:encoded>
    All the major browsers have the ability to download an XML document that has an xml-stylesheet processing instruction, understand the xml-stylesheet instruction, download the referenced XSL file and transform the downloaded XML before rendering it for the user. This means that you have the ability to even more clearly seperate the data from the design when producing web pages - have an XML feed that is the pure data, have an XSL file that transforms this XML file into (X)HTML for the browser to render and then have linked CSS files to apply visual styles to the HTML that is being rendered.&lt;br /&gt;
&lt;br /&gt;
Where this falls apart at first attempts is with the output encodings - specifically with IE trying to render the pages. It turns out that the encoding name that I keep using for everything is actually wrong. I always put an encoding of &quot;utf8&quot; on my xml documents, but the legal encoding name is actually &quot;UTF-8&quot;. In every XML and XSL capable program that I&#039;ve used, this has never been a problem which is why I never realised. &lt;br /&gt;
&lt;br /&gt;
Except for IE of course. In IE if you put in an encoding of &quot;utf8&quot; then you get the dreaded &quot;System does not support the specified encoding&quot; error that doesn&#039;t actually tell you anything. To make matters even more complicated, IE as an XML or HTML renderer can handle the name &quot;utf8&quot; perfectly well. It is only IE as an XSL processor that has trouble handling it. In other words, if you don&#039;t have an xml-stylesheet PI on your XML file, where the XML file is listed as having an encoding of &quot;utf8&quot; then IE will open it perfectly well, and will even process it with it&#039;s built in XSL file perfectly well. As soon as you put an xml-stylesheet PI onto this document, still with the encoding of &quot;utf8&quot; then it just all stops working...&lt;br /&gt;
&lt;br /&gt;
In short - to make sure that your XML and XSL files are going to work with IE, use an encoding name of &quot;UTF-8&quot; instead of &quot;utf8&quot;... 
    </content:encoded>

    <pubDate>Thu, 26 Jul 2007 15:13:22 +0100</pubDate>
    <guid isPermaLink="false">http://grahamcox.co.uk/serendipity/index.php?/archives/32-guid.html</guid>
    
</item>
<item>
    <title>Soundex, Metaphone and Double Metaphone generator</title>
    <link>http://grahamcox.co.uk/serendipity/index.php?/archives/31-Soundex,-Metaphone-and-Double-Metaphone-generator.html</link>
            <category>Coding</category>
    
    <comments>http://grahamcox.co.uk/serendipity/index.php?/archives/31-Soundex,-Metaphone-and-Double-Metaphone-generator.html#comments</comments>
    <wfw:comment>http://grahamcox.co.uk/serendipity/wfwcomment.php?cid=31</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://grahamcox.co.uk/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=31</wfw:commentRss>
    

    <author>nospam@example.com (Graham Cox)</author>
    <content:encoded>
    For something I&#039;m working on at the moment, I needed a simple way of generating &lt;a href=&quot;http://grahamcox.co.uk/serendipity/exit.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9Tb3VuZGV4&amp;amp;entry_id=31&quot; title=&quot;http://en.wikipedia.org/wiki/Soundex&quot;  onmouseover=&quot;window.status=&#039;http://en.wikipedia.org/wiki/Soundex&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Soundex&lt;/a&gt;, &lt;a href=&quot;http://grahamcox.co.uk/serendipity/exit.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9NZXRhcGhvbmU=&amp;amp;entry_id=31&quot; title=&quot;http://en.wikipedia.org/wiki/Metaphone&quot;  onmouseover=&quot;window.status=&#039;http://en.wikipedia.org/wiki/Metaphone&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Metaphone&lt;/a&gt; and &lt;a  href=&quot;http://grahamcox.co.uk/serendipity/exit.php?url=aHR0cDovL2VuLndpa2lwZWRpYS5vcmcvd2lraS9Eb3VibGVfTWV0YXBob25l&amp;amp;entry_id=31&quot; title=&quot;http://en.wikipedia.org/wiki/Double_Metaphone&quot;  onmouseover=&quot;window.status=&#039;http://en.wikipedia.org/wiki/Double_Metaphone&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Double Metaphone&lt;/a&gt; conversions of strings. As I couldn&#039;t find anything that did this easily on the web, I wrote myself one. This is found &lt;a href=&quot;http://grahamcox.co.uk/serendipity/exit.php?url=aHR0cDovL2dyYWhhbWNveC5jby51ay9jZ2ktYmluL3NvdW5kZXgucGw=&amp;amp;entry_id=31&quot; title=&quot;http://grahamcox.co.uk/cgi-bin/soundex.pl&quot;  onmouseover=&quot;window.status=&#039;http://grahamcox.co.uk/cgi-bin/soundex.pl&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Here&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The code for this uses the modules &lt;a href=&quot;http://grahamcox.co.uk/serendipity/exit.php?url=aHR0cDovL3NlYXJjaC5jcGFuLm9yZy9+bWFya20vVGV4dC1Tb3VuZGV4LTMuMDIvU291bmRleC5wbQ==&amp;amp;entry_id=31&quot; title=&quot;http://search.cpan.org/~markm/Text-Soundex-3.02/Soundex.pm&quot;  onmouseover=&quot;window.status=&#039;http://search.cpan.org/~markm/Text-Soundex-3.02/Soundex.pm&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Text::Soundex&lt;/a&gt;, &lt;a href=&quot;http://grahamcox.co.uk/serendipity/exit.php?url=aHR0cDovL3NlYXJjaC5jcGFuLm9yZy9+bXNjaHdlcm4vVGV4dC1NZXRhcGhvbmUtMS45Ni9NZXRhcGhvbmUucG0=&amp;amp;entry_id=31&quot; title=&quot;http://search.cpan.org/~mschwern/Text-Metaphone-1.96/Metaphone.pm&quot;  onmouseover=&quot;window.status=&#039;http://search.cpan.org/~mschwern/Text-Metaphone-1.96/Metaphone.pm&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Text::Metaphone&lt;/a&gt; and &lt;a href=&quot;http://grahamcox.co.uk/serendipity/exit.php?url=aHR0cDovL3NlYXJjaC5jcGFuLm9yZy9+bWF1cmljZS9UZXh0LURvdWJsZU1ldGFwaG9uZS0wLjA3L0RvdWJsZU1ldGFwaG9uZS5wbQ==&amp;amp;entry_id=31&quot; title=&quot;http://search.cpan.org/~maurice/Text-DoubleMetaphone-0.07/DoubleMetaphone.pm&quot;  onmouseover=&quot;window.status=&#039;http://search.cpan.org/~maurice/Text-DoubleMetaphone-0.07/DoubleMetaphone.pm&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Text::DoubleMetaphone&lt;/a&gt; &lt;br /&gt;&lt;a href=&quot;http://grahamcox.co.uk/serendipity/index.php?/archives/31-Soundex,-Metaphone-and-Double-Metaphone-generator.html#extended&quot;&gt;Continue reading &quot;Soundex, Metaphone and Double Metaphone generator&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Mon, 11 Jun 2007 11:12:03 +0100</pubDate>
    <guid isPermaLink="false">http://grahamcox.co.uk/serendipity/index.php?/archives/31-guid.html</guid>
    
</item>
<item>
    <title>fmemopen for Cygwin</title>
    <link>http://grahamcox.co.uk/serendipity/index.php?/archives/28-fmemopen-for-Cygwin.html</link>
            <category>Coding</category>
    
    <comments>http://grahamcox.co.uk/serendipity/index.php?/archives/28-fmemopen-for-Cygwin.html#comments</comments>
    <wfw:comment>http://grahamcox.co.uk/serendipity/wfwcomment.php?cid=28</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://grahamcox.co.uk/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=28</wfw:commentRss>
    

    <author>nospam@example.com (Graham Cox)</author>
    <content:encoded>
    The GNU GLibC library defines a function called fmemopen that allows you to open an in-memory buffer as if it was a FILE &amp;#42; handle. The LibC that Cygwin uses doesn&#039;t define this, and so this functionality is not possible.&lt;br /&gt;
&lt;br /&gt;
The below code is an implementation of fmemopen that works under Cygwin. It&#039;s far from finished, and likely to be very flakey, but simple tests do prove that it works.&lt;br /&gt;
&lt;br /&gt;
Currently missing features are:&lt;br /&gt;
** Seeking&lt;br /&gt;
** Writing into the buffer&lt;br /&gt;
&lt;br /&gt;
&lt;a  href=&quot;http://grahamcox.co.uk/serendipity/exit.php?url=aHR0cDovL2dyYWhhbWNveC5jby51ay9maWxlcy9mbWVtb3Blbi5o&amp;amp;entry_id=28&quot; title=&quot;http://grahamcox.co.uk/files/fmemopen.h&quot;  onmouseover=&quot;window.status=&#039;http://grahamcox.co.uk/files/fmemopen.h&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;fmemopen.h&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
To use it, simply #include the fmemopen.h file in your source file, and then call the fmemopen(const char &amp;#42; data, const size_t size, const char &amp;#42; mode) function to get your FILE &amp;#42; pointer.&lt;br /&gt;
&lt;br /&gt;
The fields are as follows:&lt;br /&gt;
** data: The data that you want to use.&lt;br /&gt;
** size: The size of the data to use. &lt;br /&gt;
** mode: Ignored, but included for footprint compatibility with the GLibC version.&lt;br /&gt;
&lt;br /&gt;
The actual data is memcpy&#039;d out into an internal buffer, starting at &lt;i&gt;data&lt;/i&gt;, and going for &lt;i&gt;size&lt;/i&gt; bytes. 
    </content:encoded>

    <pubDate>Tue, 16 Jan 2007 10:52:00 +0000</pubDate>
    <guid isPermaLink="false">http://grahamcox.co.uk/serendipity/index.php?/archives/28-guid.html</guid>
    
</item>
<item>
    <title>Lua Scripting</title>
    <link>http://grahamcox.co.uk/serendipity/index.php?/archives/27-Lua-Scripting.html</link>
            <category>Coding</category>
    
    <comments>http://grahamcox.co.uk/serendipity/index.php?/archives/27-Lua-Scripting.html#comments</comments>
    <wfw:comment>http://grahamcox.co.uk/serendipity/wfwcomment.php?cid=27</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://grahamcox.co.uk/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=27</wfw:commentRss>
    

    <author>nospam@example.com (Graham Cox)</author>
    <content:encoded>
    Not tested any of this yet, but this looks like a very concise and easy-to-understand introduction to embedding Lua in C++ code.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://grahamcox.co.uk/serendipity/exit.php?url=aHR0cDovL3d3dy5kZWJpYW4tYWRtaW5pc3RyYXRpb24ub3JnL2FydGljbGVzLzI2NA==&amp;amp;entry_id=27&quot; title=&quot;http://www.debian-administration.org/articles/264&quot;  onmouseover=&quot;window.status=&#039;http://www.debian-administration.org/articles/264&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;http://www.debian-administration.org/articles/264&lt;/a&gt; 
    </content:encoded>

    <pubDate>Fri, 05 Jan 2007 14:45:19 +0000</pubDate>
    <guid isPermaLink="false">http://grahamcox.co.uk/serendipity/index.php?/archives/27-guid.html</guid>
    
</item>
<item>
    <title>Website Templates</title>
    <link>http://grahamcox.co.uk/serendipity/index.php?/archives/20-Website-Templates.html</link>
            <category>Web Design</category>
    
    <comments>http://grahamcox.co.uk/serendipity/index.php?/archives/20-Website-Templates.html#comments</comments>
    <wfw:comment>http://grahamcox.co.uk/serendipity/wfwcomment.php?cid=20</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://grahamcox.co.uk/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=20</wfw:commentRss>
    

    <author>nospam@example.com (Graham Cox)</author>
    <content:encoded>
    Web design is something that people are either very good at or very bad at. I&#039;m one of the people who are very bad at it, and as such use as much help as possible from elsewhere to do the design of any websites I&#039;m working on.&lt;br /&gt;
&lt;br /&gt;
One such place is &lt;a href=&quot;http://grahamcox.co.uk/serendipity/exit.php?url=aHR0cDovL3d3dy5vc3dkLm9yZy8=&amp;amp;entry_id=20&quot; title=&quot;http://www.oswd.org/&quot;  onmouseover=&quot;window.status=&#039;http://www.oswd.org/&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Open Source Web Design&lt;/a&gt; - a repository of free to use web templates that you can just drop into place and use. This I have used a fair bit and the work is generally quite excellent.&lt;br /&gt;
&lt;br /&gt;
Another place that I have just found is &lt;a href=&quot;http://grahamcox.co.uk/serendipity/exit.php?url=aHR0cDovL3d3dy5nZXR0ZW1wbGF0ZS5jb20v&amp;amp;entry_id=20&quot; title=&quot;http://www.gettemplate.com/&quot;  onmouseover=&quot;window.status=&#039;http://www.gettemplate.com/&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;GetTemplate&lt;/a&gt; - another site with free web templates and also offering custom designs for a fee. I &lt;strong&gt;think&lt;/strong&gt; this site is run by one of the publishers who has work on OSWD, and it&#039;s his work that he is offering. 
    </content:encoded>

    <pubDate>Tue, 10 Oct 2006 13:53:08 +0100</pubDate>
    <guid isPermaLink="false">http://grahamcox.co.uk/serendipity/index.php?/archives/20-guid.html</guid>
    
</item>
<item>
    <title>getElementsBy...</title>
    <link>http://grahamcox.co.uk/serendipity/index.php?/archives/15-getElementsBy....html</link>
            <category>Javascript</category>
    
    <comments>http://grahamcox.co.uk/serendipity/index.php?/archives/15-getElementsBy....html#comments</comments>
    <wfw:comment>http://grahamcox.co.uk/serendipity/wfwcomment.php?cid=15</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://grahamcox.co.uk/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=15</wfw:commentRss>
    

    <author>nospam@example.com (Graham Cox)</author>
    <content:encoded>
    This site is a very useful reference of all the different getElement(s)By... functions available in Javascript:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://grahamcox.co.uk/serendipity/exit.php?url=aHR0cDovL3d3dy5nZXRlbGVtZW50c2J5LmNvbS8=&amp;amp;entry_id=15&quot; title=&quot;http://www.getelementsby.com/&quot;  onmouseover=&quot;window.status=&#039;http://www.getelementsby.com/&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;http://www.getelementsby.com/&lt;/a&gt; 
    </content:encoded>

    <pubDate>Thu, 17 Aug 2006 16:15:13 +0100</pubDate>
    <guid isPermaLink="false">http://grahamcox.co.uk/serendipity/index.php?/archives/15-guid.html</guid>
    
</item>
<item>
    <title>Caret Position in a text control</title>
    <link>http://grahamcox.co.uk/serendipity/index.php?/archives/13-Caret-Position-in-a-text-control.html</link>
            <category>Code Snippets</category>
            <category>Cross-Browser</category>
    
    <comments>http://grahamcox.co.uk/serendipity/index.php?/archives/13-Caret-Position-in-a-text-control.html#comments</comments>
    <wfw:comment>http://grahamcox.co.uk/serendipity/wfwcomment.php?cid=13</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://grahamcox.co.uk/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=13</wfw:commentRss>
    

    <author>nospam@example.com (Graham Cox)</author>
    <content:encoded>
    Once again, IE proves that it can&#039;t do anything in a standard way. &lt;br /&gt;
&lt;br /&gt;
Retrieving the caret position from a text control in Firefox and Opera is a very simple job - you simply use the selectionStart and selectionEnd parameters of the control itself.&lt;br /&gt;
&lt;br /&gt;
Retrieving the caret position from a text control in IE is not quite so simple. There are no parameters that give you this information, so you have to work it out for yourself. As it happens, there are a number of ways of doing this available on the internet. Unfortunatly, none of them work properly.&lt;br /&gt;
&lt;br /&gt;
The &quot;official&quot; method of doing it according to the Microsoft Web Team in the article &lt;a href=&quot;http://grahamcox.co.uk/serendipity/exit.php?url=aHR0cDovL21zZG4ubWljcm9zb2Z0LmNvbS9saWJyYXJ5L2RlZmF1bHQuYXNwP3VybD0vbGlicmFyeS9lbi11cy9kaHRtbHRlY2hjb2wvY29scy9kbndlYnRlYW0vd2VidGVhbTEyMDMyMDAxLmFzcA==&amp;amp;entry_id=13&quot; title=&quot;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dhtmltechcol/cols/dnwebteam/webteam12032001.asp&quot;  onmouseover=&quot;window.status=&#039;http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dhtmltechcol/cols/dnwebteam/webteam12032001.asp&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Yule Not Want to Miss this One&lt;/a&gt; (See &quot;O Cursor, Where Art Thou—finding yourself in a text box&quot;) is just horrible:&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Save the input field value in a temporary variable. &lt;/li&gt;&lt;li&gt;Create a TextRange object on the document.selection (assuming the input field is focused). &lt;/li&gt;&lt;li&gt;Insert a “~” character into that TextRange object (range.text = &quot;~&quot;). Thus, the tilde would be inserted at the caret position (which we actually want to determine). &lt;/li&gt;&lt;li&gt;Search for the “~” character in the input field value and remember the index where it was found. &lt;br /&gt;
Restore the original input field value, saved at (1). &lt;/li&gt;&lt;li&gt;Return the index determined at (4) and claim it is the caret position.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;
&lt;br /&gt;
The better method of doing it uses undocumented features of the Range object, and is &lt;a href=&quot;http://grahamcox.co.uk/serendipity/exit.php?url=aHR0cDovL3d3dy5iYXpvbi5uZXQvbWlzaG9vL2FydGljbGVzLmVwbD9hcnRfaWQ9MTI5Mg==&amp;amp;entry_id=13&quot; title=&quot;http://www.bazon.net/mishoo/articles.epl?art_id=1292&quot;  onmouseover=&quot;window.status=&#039;http://www.bazon.net/mishoo/articles.epl?art_id=1292&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;described here by Mishoo&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
This uses the Range.getBookmark() function which returns a value that can be used to get to the caret position. It worked fine. And in IE7 it stopped working. Microsoft changed the way this function worked (It&#039;s undocumented and so they can do that) and broke things that rely on it.&lt;br /&gt;
&lt;br /&gt;
The third method of working out the caret position, which I have not seen mentioned anywhere on the internet and so might very well not work properly, is to use the Range.offsetLeft value. This gives you a value which represents the distance from the start of the text field that the caret is located at. In standard mode, this value is (position * 7) + 1. &lt;br /&gt;
&lt;br /&gt;
This has been tested in IE5, IE5.5, IE6 and IE7 and returns the same values across all of them. It also returns the same value regardless of the zoom of the page and the location of the textbox on the screen.&lt;br /&gt;
&lt;br /&gt;
As such, below is my cross-browser function to get the caret position from a given text field. It is known to work in Firefox, Opera, Netscape and (now) all versions of IE from 5.5 and up. &lt;br /&gt;&lt;a href=&quot;http://grahamcox.co.uk/serendipity/index.php?/archives/13-Caret-Position-in-a-text-control.html#extended&quot;&gt;Continue reading &quot;Caret Position in a text control&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Fri, 21 Jul 2006 10:23:52 +0100</pubDate>
    <guid isPermaLink="false">http://grahamcox.co.uk/serendipity/index.php?/archives/13-guid.html</guid>
    
</item>
<item>
    <title>IE7 Keyboard entry woes</title>
    <link>http://grahamcox.co.uk/serendipity/index.php?/archives/12-IE7-Keyboard-entry-woes.html</link>
            <category>Coding</category>
            <category>Cross-Browser</category>
    
    <comments>http://grahamcox.co.uk/serendipity/index.php?/archives/12-IE7-Keyboard-entry-woes.html#comments</comments>
    <wfw:comment>http://grahamcox.co.uk/serendipity/wfwcomment.php?cid=12</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://grahamcox.co.uk/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=12</wfw:commentRss>
    

    <author>nospam@example.com (Graham Cox)</author>
    <content:encoded>
    It seems that IE7 have managed to make things even worse in the cross-browser keyboard handling arena.&lt;br /&gt;
&lt;br /&gt;
From some simple testing, it would appear that either IE7 updates the caret position &lt;strong&gt;before&lt;/strong&gt; the keypress event is triggered, even though the new character isn&#039;t yet entered (and might not be entered), or (and this is more likely) the caret positions are now 1-indexed and not 0-indexed like everybody else uses.&lt;br /&gt;
&lt;br /&gt;
For the vast majority of cases out there, this is not going to cause any problems at all, but if you do care about where the character being entered is meant to go in a cross-browser manner then it would appear that you are in trouble. Essentially all it means is that in IE7 your caret positions are always going to be one greater than they are in the other browsers, but it&#039;s enough of a difference to cause problems...&lt;br /&gt;
&lt;br /&gt;
Edit: (See above) It appears that the problem is really that Microsoft changed the undocumented feature that I was using to get the caret position. I was using this because there is no documented way to get at the position that is worth considering. 
    </content:encoded>

    <pubDate>Thu, 20 Jul 2006 17:27:02 +0100</pubDate>
    <guid isPermaLink="false">http://grahamcox.co.uk/serendipity/index.php?/archives/12-guid.html</guid>
    
</item>
<item>
    <title>Cross-Browser event object</title>
    <link>http://grahamcox.co.uk/serendipity/index.php?/archives/9-Cross-Browser-event-object.html</link>
            <category>Code Snippets</category>
            <category>Cross-Browser</category>
    
    <comments>http://grahamcox.co.uk/serendipity/index.php?/archives/9-Cross-Browser-event-object.html#comments</comments>
    <wfw:comment>http://grahamcox.co.uk/serendipity/wfwcomment.php?cid=9</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://grahamcox.co.uk/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=9</wfw:commentRss>
    

    <author>nospam@example.com (Graham Cox)</author>
    <content:encoded>
    Different browsers handle events in different ways. Unfortunatly, this means that the same function will receive it&#039;s data in different ways on different browsers. From the major three:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Firefox. Event object is passed as parameter to the callback function&lt;/li&gt;&lt;li&gt;Opera. Event object is passed as a parameter to the callback function. Some members of event object have different names&lt;/li&gt;&lt;li&gt;Internet Explorer. No parameters passed to callback function. Event object exists as a global variable(!) instead. Some members of event object have different names.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
Whilst Internet Explorer does use a global variable to store the event object, this is actually less of a problem since the javascript engine is single-threaded. It shouldn&#039;t be possible to have two event handlers for two different events using the same event object. This could change in IE7 or later however, at which time things will likely all stop working in a horrible manner.&lt;br /&gt;
&lt;br /&gt;
This snippit can be called, being passed the event parameter from the event handler, and will return an event object in a standardised way. Note that this is nowhere near finished, and still has a lot of work needed to cover everything. In specific, keyboard handling is very rudimentary (see below) and mouse handling is non-existant.  &lt;br /&gt;&lt;a href=&quot;http://grahamcox.co.uk/serendipity/index.php?/archives/9-Cross-Browser-event-object.html#extended&quot;&gt;Continue reading &quot;Cross-Browser event object&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Mon, 17 Jul 2006 17:34:54 +0100</pubDate>
    <guid isPermaLink="false">http://grahamcox.co.uk/serendipity/index.php?/archives/9-guid.html</guid>
    
</item>
<item>
    <title>Keyboard handling and Opera</title>
    <link>http://grahamcox.co.uk/serendipity/index.php?/archives/8-Keyboard-handling-and-Opera.html</link>
            <category>Cross-Browser</category>
            <category>Opera</category>
    
    <comments>http://grahamcox.co.uk/serendipity/index.php?/archives/8-Keyboard-handling-and-Opera.html#comments</comments>
    <wfw:comment>http://grahamcox.co.uk/serendipity/wfwcomment.php?cid=8</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://grahamcox.co.uk/serendipity/rss.php?version=2.0&amp;type=comments&amp;cid=8</wfw:commentRss>
    

    <author>nospam@example.com (Graham Cox)</author>
    <content:encoded>
    Keyboard handling in Javascript events gives a whole new meaning to &quot;impossible&quot;. It turns out that there is simply no reliable way to do this and still have your code work across the board.&lt;br /&gt;
&lt;br /&gt;
The main problem here turns out to be Opera. Opera, in their ultimate wisdom, have decided that in the &lt;i&gt;keypress&lt;/i&gt; event they will give you the &lt;i&gt;Keyboard code&lt;/i&gt; for function keys, and &lt;i&gt;Character code&lt;/i&gt; for all other keys. The problem is that they give you this code in the same variable in the event object. &lt;br /&gt;
&lt;br /&gt;
The problem comes from the fact that the keyboard code and the character code can, and often do, overlap each other. For example, the character code for the period character is 46. It just so happens that the keyboard code for the delete key is also 46. Having compared the event object that is passed into the keypress event when the period and the delete key are pressed, the event objects are identical. There is not a single way to tell the difference between those two keys in that event!&lt;br /&gt;
&lt;br /&gt;
As it happens, the reason I was trying to do this was to have a text field that only allows certain keys to be pressed. Period wasn&#039;t one of the keys, but I did want all the function keys to work (arrows, delete, home, end, etc). Another &quot;feature&quot; of Opera is that these keys can not be cancelled. As such, if I think it might be a period I can try and cancel it, and if it&#039;s a period it&#039;s cancelled and if it&#039;s a delete then it&#039;s not. 
    </content:encoded>

    <pubDate>Mon, 17 Jul 2006 13:52:31 +0100</pubDate>
    <guid isPermaLink="false">http://grahamcox.co.uk/serendipity/index.php?/archives/8-guid.html</guid>
    
</item>

</channel>
</rss>