Convert String to Zenkaku Case - Node.js String

Node.js examples for String:Case

Description

Convert String to Zenkaku Case

Demo Code


String.prototype.toZenkakuCase = function()
{
  var c, i = this.length, a = [];

  while(i--)//from   w ww  .j  a va2  s. c om
  {
    c = a[i] = this.charCodeAt(i);
    switch(true)
    {
      case (c <= 0x007E && 0x0021 <= c):
        a[i] += 0xFEE0;
        break;
      case (c == 0x0020):
        a[i] = 0x3000;
        break;
    };
  };

  return String.fromCharCode.apply(null, a);
};

Related Tutorials