{
  "attachments": [],
  "comments_archived": true,
  "date": "2005-08-19T21:32:12.000Z",
  "layout": "post",
  "title": "Super-fast DummyPants Addressbarlet for del.icio.us",
  "wordpress_id": 676,
  "wordpress_slug": "dummypants",
  "wordpress_url": "http://www.decafbad.com/blog/?p=676",
  "year": "2005",
  "month": "08",
  "day": "19",
  "isDir": false,
  "slug": "dummypants",
  "type": "entry",
  "postName": "2005-08-19-dummypants",
  "html": "<p>Okay, so lately I've switched to using \"<a href=\"http://naeblis.cx/rtomayko/2004/08/09/DeliciousAddresslets\">addressbarlets</a>\" for my <a href=\"http://del.icio.us\">del.icio.us</a> posting needs.  In particular, I've been using the <a href=\"http://ejohn.org/blog/super-fast-delicious-bookmarklet/\">Super-Fast variety</a>.  I cannot stress how much better these are than clicking links in the bookmark toolbar.  My <a href=\"http://del.icio.us\">del.icio.us</a> posting has converged that much closer to command-line / QuickSilver perfection.  </p>\n<p>But, I just noticed that in my <a href=\"http://del.icio.us\">del.icio.us</a> RSS feed, the title \"<strong>del.icio.us warning: non-utf8 string! (sorry)</strong>\" has been popping up--especially on <a href=\"http://dev.upian.com/hotlinks/\">Hot Links</a>, which includes my links on a regular basis.  </p>\n<p>Well, although I'm not really all that hip to unicode and non-ASCII characters, it appears that things like <a href=\"http://daringfireball.net/projects/smartypants/\">SmartyPants</a> and the <a href=\"http://www.365tomorrows.com/08/19/deo%e2%80%99s-hole/\">use of chevrons in page titles</a> are throwing the monkey wrench for me when the addressbarlet picks up the <code>document.title</code>.  So, I decided to do a little sloppy butchery in my bookmarklet code to wrestle these titles into something acceptable.</p>\n<p>After you've had a chance to try out / comprehend <a href=\"http://ejohn.org/blog/super-fast-delicious-bookmarklet/\">the original versions</a>, take a look at this revised addressbarlet:</p>\n<ul>\n<li><a href=\"javascript:u=%22CHANGEME%22;us=[['\\u201C','%22'],['\\u201D','%22'],['\\u2019',%22'%22],['\\u2018',%22'%22],['\\u2026',%22...%22],['\\u00BB','-']];function es(p){for(var i=0;i<us.length;i++){p=p.replace(us[i][0],us[i][1])};p=p.replace(/[\\u0080-\\uFFFF]/g,'');return encodeURIComponent(p);};q=location.href;e=%22%22+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);p=document.title;window.location.href=%22http://del.icio.us/%22+u+%22?jump=doclose&amp;tags=%22+es(%22%s%22)+%22&amp;url=%22+es(q)+%22&amp;description=%22+es(p)+%22&amp;extended=%22+es('%22'+e+'%22').replace(/ /g,%22+%22);\">Post to del.icio.us and close</a></li>\n</ul>\n<p>In case, for some reason, that doesn't come through in this entry, here's the code which should appear in the HREF:</p>\n<textarea rows=\"10\" cols=\"65\" name=\"code\" class=\"javascript\">    javascript:u=%22CHANGEME%22;us=[['\\u201C','%22'],['\\u201D','%22'],['\\u2019',%22'%22],['\\u2018',%22'%22],['\\u2026',%22...%22],['\\u00BB','-']];function es(p){for(var i=0;i&lt;us .length;i++){p=p.replace(us[i][0],us[i][1])};p=p.replace(/[\\u0080-\\uFFFF]/g,'');return encodeURIComponent(p);};q=location.href;e=%22%22+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);p=document.title;window.location.href=%22http://del.icio.us/%22+u+%22?jump=doclose&amp;tags=%22+es(%22%s%22)+%22&amp;url=%22+es(q)+%22&amp;description=%22+es(p)+%22&amp;extended=%22+es('%22'+e+'%22').replace(/ /g,%22+%22);</textarea>\n<p>I'm sure I have a few nasty bugs lurking in there, but basically I'm trying to reverse <a href=\"http://daringfireball.net/projects/smartypants/\">SmartyPants</a>--DummyPants, if you will--and crudely hack out everything that's not the usual ASCII.</p>\n<p>If you happen to be having this problem, let me know if this code works for you.</p>\n<!--more-->\n\n\n<p>shortname=dummypants</p>\n<div id=\"comments\" class=\"comments archived-comments\"><h3>Archived Comments</h3>\n<ul class=\"comments\">\n<li class=\"comment\" id=\"comment-221088797\">\n<div class=\"meta\">\n<div class=\"author\">\n<a class=\"avatar image\" rel=\"nofollow\" href=\"http://plasmasturm.org/\"><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=e17949267bbfe21a0fadf1bbf00592b4&amp;size=32&amp;default=http://mediacdn.disqus.com/1320279820/images/noavatar32.png\" width=\"\" height=\"\"></a>\n<a class=\"avatar name\" rel=\"nofollow\" href=\"http://plasmasturm.org/\">Aristotle Pagaltzis</a>\n</div>\n\n\n<p><a href=\"#comment-221088797\" class=\"permalink\"><time datetime=\"2005-08-20T00:47:22\">2005-08-20T00:47:22</time></a></p>\n</div>\n\n\n<div class=\"content\">del.icio.us understands UTF-8 (which is exactly what the message says, after all), and the characters you remove are expressed in Unicode codepoints.\nThe disconnect seems to happen when the page you're on is in an encoding other than UTF-8, in which case Firefox apparently escapes characters using their byte values from that encoding in `encodeURIComponent`. I have no idea why, or exactly where this problem happens; the JS docs say the function should always use the UTF-8 representation for the byte values.</div>\n\n\n</li>\n<li class=\"comment\" id=\"comment-221088798\">\n<div class=\"meta\">\n<div class=\"author\">\n<a class=\"avatar image\" rel=\"nofollow\" href=\"http://ejohn.org/\"><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=b3e04a46e85ad3e165d66f5d927eb609&amp;size=32&amp;default=http://mediacdn.disqus.com/1320279820/images/noavatar32.png\" width=\"\" height=\"\"></a>\n<a class=\"avatar name\" rel=\"nofollow\" href=\"http://ejohn.org/\">John Resig</a>\n</div>\n\n\n<p><a href=\"#comment-221088798\" class=\"permalink\"><time datetime=\"2005-08-20T19:30:38\">2005-08-20T19:30:38</time></a></p>\n</div>\n\n\n<div class=\"content\">A very smart improvement of the original - I like it! I'll see if I can't include a link to it, before I forget.</div>\n\n\n</li>\n</ul>\n\n\n</div>\n\n\n",
  "body": "Okay, so lately I've switched to using \"[addressbarlets][addr]\" for my [del.icio.us][] posting needs.  In particular, I've been using the [Super-Fast variety][superfast].  I cannot stress how much better these are than clicking links in the bookmark toolbar.  My [del.icio.us][] posting has converged that much closer to command-line / QuickSilver perfection.  \r\n\r\nBut, I just noticed that in my [del.icio.us][] RSS feed, the title \"**del.icio.us warning: non-utf8 string! (sorry)**\" has been popping up--especially on [Hot Links][hl], which includes my links on a regular basis.  \r\n\r\nWell, although I'm not really all that hip to unicode and non-ASCII characters, it appears that things like [SmartyPants][] and the [use of chevrons in page titles][story] are throwing the monkey wrench for me when the addressbarlet picks up the `document.title`.  So, I decided to do a little sloppy butchery in my bookmarklet code to wrestle these titles into something acceptable.\r\n\r\nAfter you've had a chance to try out / comprehend [the original versions][superfast], take a look at this revised addressbarlet:\r\n\r\n* <a href=\"javascript:u=%22CHANGEME%22;us=[['\\u201C','%22'],['\\u201D','%22'],['\\u2019',%22'%22],['\\u2018',%22'%22],['\\u2026',%22...%22],['\\u00BB','-']];function es(p){for(var i=0;i<us.length;i++){p=p.replace(us[i][0],us[i][1])};p=p.replace(/[\\u0080-\\uFFFF]/g,'');return encodeURIComponent(p);};q=location.href;e=%22%22+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);p=document.title;window.location.href=%22http://del.icio.us/%22+u+%22?jump=doclose&#38;tags=%22+es(%22%s%22)+%22&#38;url=%22+es(q)+%22&#38;description=%22+es(p)+%22&#38;extended=%22+es('%22'+e+'%22').replace(/ /g,%22+%22);\">Post to del.icio.us and close</a>\r\n\r\nIn case, for some reason, that doesn't come through in this entry, here's the code which should appear in the HREF:\r\n\r\n<textarea rows=\"10\" cols=\"65\" name=\"code\" class=\"javascript\">\r\n    javascript:u=%22CHANGEME%22;us=[['\\u201C','%22'],['\\u201D','%22'],['\\u2019',%22'%22],['\\u2018',%22'%22],['\\u2026',%22...%22],['\\u00BB','-']];function es(p){for(var i=0;i<us .length;i++){p=p.replace(us[i][0],us[i][1])};p=p.replace(/[\\u0080-\\uFFFF]/g,'');return encodeURIComponent(p);};q=location.href;e=%22%22+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);p=document.title;window.location.href=%22http://del.icio.us/%22+u+%22?jump=doclose&#38;tags=%22+es(%22%s%22)+%22&#38;url=%22+es(q)+%22&#38;description=%22+es(p)+%22&#38;extended=%22+es('%22'+e+'%22').replace(/ /g,%22+%22);</textarea>\r\n\t\r\nI'm sure I have a few nasty bugs lurking in there, but basically I'm trying to reverse [SmartyPants][]--DummyPants, if you will--and crudely hack out everything that's not the usual ASCII.\r\n\r\nIf you happen to be having this problem, let me know if this code works for you.\r\n\r\n[story]: http://www.365tomorrows.com/08/19/deo%e2%80%99s-hole/\r\n[smartypants]: http://daringfireball.net/projects/smartypants/\r\n[hl]: http://dev.upian.com/hotlinks/\r\n[superfast]: http://ejohn.org/blog/super-fast-delicious-bookmarklet/\r\n[del.icio.us]: http://del.icio.us\r\n[addr]: http://naeblis.cx/rtomayko/2004/08/09/DeliciousAddresslets\r\n<!--more-->\r\nshortname=dummypants</us></textarea>\n\n<div id=\"comments\" class=\"comments archived-comments\">\n            <h3>Archived Comments</h3>\n            \n        <ul class=\"comments\">\n            \n        <li class=\"comment\" id=\"comment-221088797\">\n            <div class=\"meta\">\n                <div class=\"author\">\n                    <a class=\"avatar image\" rel=\"nofollow\" \n                       href=\"http://plasmasturm.org/\"><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=e17949267bbfe21a0fadf1bbf00592b4&amp;size=32&amp;default=http://mediacdn.disqus.com/1320279820/images/noavatar32.png\"/></a>\n                    <a class=\"avatar name\" rel=\"nofollow\" \n                       href=\"http://plasmasturm.org/\">Aristotle Pagaltzis</a>\n                </div>\n                <a href=\"#comment-221088797\" class=\"permalink\"><time datetime=\"2005-08-20T00:47:22\">2005-08-20T00:47:22</time></a>\n            </div>\n            <div class=\"content\">del.icio.us understands UTF-8 (which is exactly what the message says, after all), and the characters you remove are expressed in Unicode codepoints.\n\nThe disconnect seems to happen when the page you're on is in an encoding other than UTF-8, in which case Firefox apparently escapes characters using their byte values from that encoding in `encodeURIComponent`. I have no idea why, or exactly where this problem happens; the JS docs say the function should always use the UTF-8 representation for the byte values.</div>\n            \n        </li>\n    \n        <li class=\"comment\" id=\"comment-221088798\">\n            <div class=\"meta\">\n                <div class=\"author\">\n                    <a class=\"avatar image\" rel=\"nofollow\" \n                       href=\"http://ejohn.org/\"><img src=\"http://www.gravatar.com/avatar.php?gravatar_id=b3e04a46e85ad3e165d66f5d927eb609&amp;size=32&amp;default=http://mediacdn.disqus.com/1320279820/images/noavatar32.png\"/></a>\n                    <a class=\"avatar name\" rel=\"nofollow\" \n                       href=\"http://ejohn.org/\">John Resig</a>\n                </div>\n                <a href=\"#comment-221088798\" class=\"permalink\"><time datetime=\"2005-08-20T19:30:38\">2005-08-20T19:30:38</time></a>\n            </div>\n            <div class=\"content\">A very smart improvement of the original - I like it! I'll see if I can't include a link to it, before I forget.</div>\n            \n        </li>\n    \n        </ul>\n    \n        </div>\n    ",
  "parentPath": "./content/posts/archives/2005",
  "path": "2005/08/19/dummypants",
  "summary": "Okay, so lately I've switched to using \"addressbarlets\" for my del.icio.us posting needs.  In particular, I've been using the Super-Fast variety.  I cannot stress how much better these are than clicking links in the bookmark toolbar.  My del.icio.us posting has converged that much closer to command-line / QuickSilver perfection.  \nBut, I just noticed that in my del.icio.us RSS feed, the title \"del.icio.us warning: non-utf8 string! (sorry)\" has been popping up--especially on Hot Links, which includes my links on a regular basis.  \nWell, although I'm not really all that hip to unicode and non-ASCII characters, it appears that things like SmartyPants and the use of chevrons in page titles are throwing the monkey wrench for me when the addressbarlet picks up the document.title.  So, I decided to do a little sloppy butchery in my bookmarklet code to wrestle these titles into something acceptable.\nAfter you've had a chance to try out / comprehend the original versions, take a look at this revised addressbarlet:\n\nPost to del.icio.us and close\n\nIn case, for some reason, that doesn't come through in this entry, here's the code which should appear in the HREF:\n    javascript:u=%22CHANGEME%22;us=[['\\u201C','%22'],['\\u201D','%22'],['\\u2019',%22'%22],['\\u2018',%22'%22],['\\u2026',%22...%22],['\\u00BB','-']];function es(p){for(var i=0;i<us .length;i++){p=p.replace(us[i][0],us[i][1])};p=p.replace(/[\\u0080-\\uFFFF]/g,'');return encodeURIComponent(p);};q=location.href;e=%22%22+(window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);p=document.title;window.location.href=%22http://del.icio.us/%22+u+%22?jump=doclose&tags=%22+es(%22%s%22)+%22&url=%22+es(q)+%22&description=%22+es(p)+%22&extended=%22+es('%22'+e+'%22').replace(/ /g,%22+%22);\nI'm sure I have a few nasty bugs lurking in there, but basically I'm trying to reverse SmartyPants--DummyPants, if you will--and crudely hack out everything that's not the usual ASCII.\nIf you happen to be having this problem, let me know if this code works for you.",
  "needsBuild": true,
  "prevPostPath": "2005/08/12/quick-and-random-thoughts",
  "prevPostTitle": "Quick and Random Thoughts",
  "nextPostPath": "2005/08/25/my-brains-full-of-fog",
  "nextPostTitle": "My brain's full of fog"
}