Force the X-Page-Title value to be treated as UTF-8
authorTom Hughes <tom@compton.nu>
Sun, 1 Dec 2013 20:31:48 +0000 (20:31 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 1 Dec 2013 20:31:48 +0000 (20:31 +0000)
This is basically a black magic hack to get javascript to treat
a string as UTF-8 and decode it to the correct form.

http://monsur.hossa.in/2012/07/20/utf-8-in-javascript.html

app/assets/javascripts/index.js

index 1f9e6c8916a659e63d5cfacd923c94f27afcf8de..1cbd97f86351e442f210d320e41167c5f42b1969 100644 (file)
@@ -46,7 +46,8 @@
         var content = $(xhr.responseText);
 
         if (xhr.getResponseHeader('X-Page-Title')) {
-          document.title = xhr.getResponseHeader('X-Page-Title');
+          var title = xhr.getResponseHeader('X-Page-Title');
+          document.title = decodeURIComponent(escape(title));
         }
 
         $('head')