Fixes #17053.  Delay escaping special characters so that character counts are accurate.  Added automated test.

git-svn-id: http://svn.dojotoolkit.org/src/branches/1.8/dijit@31413 560b804f-0ae3-0310-86f3-f6aa0a117693