title: Javascript convert unicode string to "Title Case"
body: <p>I have a javascript case conversion problem which I cannot solve due to non-English letters. My main concern is the Turkish alphabet.</p>
  
  <p>What I need to do is this:</p>
  
  <ul>
  <li>hello world => Hello World</li>
  <li>HELLO WORLD => Hello World</li>
  <li>hELLO wOrLd => Hello World</li>
  </ul>
  
  <p>Here is what I've accomplished so far:</p>
  
  <pre><code>String.prototype.turkishToUpper = function(){
      var stringlow = this;
      var letterslow = { 'i': 'İ', 'ş': 'Ş', 'ğ': 'Ğ', 'ü': 'Ü', 'ö': 'Ö', 'ç': 'Ç', 'ı': 'I' };
      stringlow = stringlow.replace(/(([iışğüçö]))/g, function(letterlow){ return letterslow[letterlow]; })
      return stringlow.toUpperCase();
  }
  
  String.prototype.turkishToLower = function(){
      var stringup = this;
      var lettersup = { 'İ': 'i', 'I': 'ı', 'Ş': 'ş', 'Ğ': 'ğ', 'Ü': 'ü', 'Ö': 'ö', 'Ç': 'ç' };
      stringup = stringup.replace(/(([İIŞĞÜÇÖ]))/g, function(letterup){ return lettersup[letterup]; })
      return stringup.toLowerCase();
  }
  
  String.prototype.toProperCase = function () {
      return this.replace(/\w\S*/g, function(txt){return txt.charAt(0).turkishToUpper() + txt.substr(1).turkishToLower();});
  };
  </code></pre>
  
  <p>But this does not give me the correct results and I am suspecting the regex replace not being usable on unicode, but ascii.</p>
  
  <p>When I test with Turkish characters, I get wrong results.</p>
  
  <ul>
  <li>şeker becomes <strong>şEker</strong> instead of <strong>Şeker</strong></li>
  <li>çoban ırmak becomes <strong>çOban ıRmak</strong> intead of <strong>Çoban Irmak</strong></li>
  </ul>
  
  <p>Also, if this can ever get resolved, I need an icing on the cake to separate words not only by spaces, but also by some other stop characters such as : - = / etc so that</p>
  
  <ul>
  <li>hello-world becomes Hello-World</li>
  <li>hello:world becomes Hello:World</li>
  </ul>
  
  <p>I've read through many similar questions here on SO, but no luck so far.</p>
  
  <p>Thanks</p>
  
  <p><em>Note: I think this is called Title Case but some have argued that it is Pascal Case. To be frank, I am interested in resolving the unicode issue (which I believe is the root cause) rather than semantics, so please forgive me if I've used wrong terminology :)</em></p>