UTF-8长度


  转为UFT-8长度

 /*
				 *  修改为支持utf8长度的判断
				*/
				for (var i = 0; i < val.length; i++) 
				{
		          charCode = val.charCodeAt(i);
		          if (charCode < 0x007f) 
				  {
		            len = len + 1;
		          } else if ((0x0080 <= charCode) && (charCode <= 0x07ff)) 
				  {
		            len += 2;
		          } else if ((0x0800 <= charCode) && (charCode <= 0xffff)) 
				  {
		            len += 3;
		          }
		        }

你可能感兴趣的:(utf-8)