I use JavaScript to grab the title of the webpage a script runs on and send it to a server for recording by outputting an image with the webpage name in the URL (and the image is the remote script that records it).

Something like this:
Code javascript:
document.write('<img src="http://www.example.com/image.php?title=' 
  + escape(document.title) 
  + '" />');

Do I know anything about the encoding of that text when I get it? Since every page the script resides on can have different encoding, is there any way to reliably record the webpage title without bungling characters outside the US-ASCII range?