Sunday, January 22, 2012

Thursday, January 12, 2012

version 0.1.4

Version 0.1.4 of World of Crosswords is now up. This is a bug fix update.

The following issues were fixed:
  1. Logged in users can now save any number of crossword puzzles that they're working on. If you're not logged in, as usual, you can only save up to four.
  2. When using the arrow keys, navigation now mimics the behavior of WordWeb's Crossword Solver. So you can now switch between a highlighted row or column without clicking on the mouse. If a row is highlighted, and you hit the up or down key, then the selected square does not move; instead, the column becomes highlighted. If a column is highlighted, and you hit the left or right arrow key, then the row becomes highlighted.
  3. Easter eggs were only showing up when the page was freshly loaded, not when using the "new puzzle" or "load saved puzzle" buttons. This has been fixed so that easter eggs now appear when those buttons are used.
  4. Easter eggs have been moved so they appear near the mouse click which produced them, making them a little easier to find.

ISO-8859-1 vs UTF-8

This is a developer note. Just ignore it if you only visit here for crossword-y stuff.

Our earliest crosswords had typical letters in the clues, no peculiarities like diacritics. For example, in the "trick or treat" puzzle, 1D is clued with "Snag". A perfectly ordinary English word, no special characters.

In next week's puzzle, themed "chocolate", 43D is clued "Dalí contemporary". With that accent on the "i", we found a bug in the site.

The clue looks fine when querying the database, but that doesn't really tell you anything. For all you know, your database client is encoding the characters differently from your web server.

And indeed, in previewing this puzzle, I could see that the clue looked incorrect on the website. The "í" looked like "í".

I'm familiar with this problem from previous work with PHP based web sites, so I knew what to look for. I was pretty sure the database encoding was fine, and the problem was in the way the web page was being displayed. Eventually I got to this page which explained the solution really well.

I looked at the header info in Firebug, and found it was ISO-8859-1 (aka Latin-1). I thought that should be OK, because "í" is part of the ISO-8859-1 character set. However, somewhere along the way, that ISO-8859-1 character is apparently being converted to UTF-8, while the web page displays it as ISO-8859-1. At least I think this is what's happening.

I also found a page at Blue Box which indicates you've got problems if your database is using latin1 encoding. I am in that situation and really don't have control over it (not my db server). Here's the related query:

mysql> show variables like 'char%';
+--------------------------+----------------------------------------------+
| Variable_name | Value |
+--------------------------+----------------------------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /data/mysql/brackemyre/share/mysql/charsets/ |
+--------------------------+----------------------------------------------+
8 rows in set (0.01 sec)

OK that's not nice, but not much I can do about it.

In the end, I added this code to the top of my PHP file:
header('Content-Type: text/html; charset=utf-8');

I also added a meta tag to my HTML: 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

This fixed the problem, as you can see from the screenshot below:
The fix was remarkably easy, whew. Internationalization can sometimes be a real pain.

Tuesday, January 10, 2012

Crossword puzzle resources

I've started collecting links which are crossword related. I'll use this post to keep the list.
  1. Crosswords Online: Cruciverbalizing on the Web by Kirk McElhearn This article is from 2003, so it's a little out of date. It's mainly focused on the NY Times puzzle, and it has a nice summary of crossword puzzle applications (primarily focused on Macs).
  2. Ray Hamel's crossword page has a thorough list of links to crossword resources on the web.

Sunday, January 1, 2012

Happy New Year!

The puzzle for this week is themed "Happy New Year!". I think it's one of our best so far. Hope you enjoy it!