blog.jj5.net (2003 to 2005)

Complacent..? Who? Me?

Fri Apr 22 20:08:00 UTC+1000 2005

Categories:

You're kidding, right Stuart? :)

It's 6am.

I'm watching the effects of FUCKED STRINGS (well, probably not... I think it's worse than that...)

I've been playing with a reg exp parser that will validate based upon %uXXXX values.

But, then, I discovered I don't actually know anything about it...

So I thought I'd see what would happen if I wrote this [1].

Woohoo! It just finished as I was typing this message.

Going now.

[1]

<!doctype html
     public "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

  <head>

    <title>  </title>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
    <meta name="author" content="John Elliot - jj5@jj5.net"/>
    <meta name="description" content=""/>
    <meta name="Morpheus" content="I'm looking for you."/>

    <script type="text/javascript">

      function RunTest() {

        var inputTextBox = document.getElementById( "inputTextBox" );
        var expressionTextBox = document.getElementById( "expressionTextBox" );

        var escapedInputTextBox = document.getElementById( "escapedInputTextBox" );

        var input = inputTextBox.value;
        var expression = expressionTextBox.value;

        WriteLine( input );
        WriteLine( expression );

        var escapedInput = escape( input );

        escapedInputTextBox.value = escapedInput;

        //WriteUnicodeRange( 256, 512 );

        //WriteUnicodeRange( 65536-256, 65536 );

        WriteUnicodeRange( 256, 65536 );

      }

      function WriteUnicodeRange( start, end ) {

        var table = "<table>";

        for ( var i = start; i < end; i++ ) {

          var hex = i.toString( 16 ).toUpperCase();

          while ( hex.length < 4 ) {

            hex = "0" + hex;

          }

          var escaped = "%u" + hex;

          try {

            table += "<tr><td>" + hex + "</td><td>" + "&#x" + hex + ";</td><td>" + unescape( escaped ) + "</td></tr>";

          }
          catch ( ex ) {

            table += "<tr><td>" + hex + "</td><td colspan=\"2\"><font color=\"red\">" + ex + "</font></td></tr>";

          }

          //if ( ( i % 50 ) == 0 ) { WriteLine(); }

        }

        table += "</table>";

        Write( table );

      }

      var output;

      function Write( str ) {

        if ( output == null ) { output = document.getElementById( "output" ); }

        output.innerHTML += str;

      }

      function WriteLine( line ) {

        if ( line == null ) { line = ""; }

        Write( line + "<br />" );

      }

    </script>

  </head>

  <body>

    <form>

      <input id="inputTextBox" type="text" /> <br />

      <input id="expressionTextBox" type="text" /> <br />

      <button onclick="RunTest();">Run Test</button> <br />

      <input id="escapedInputTextBox" type="text" /> <br />

    </form>

    <p id="output" />

  </body>
</html>


Copyright © 2003-2005 John Elliot