<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>welefen的随笔</title>
	<atom:link href="http://www.welefen.com/tag/byte/feed" rel="self" type="application/rss+xml" />
	<link>http://www.welefen.com</link>
	<description>前端打杂者@baidu</description>
	<lastBuildDate>Tue, 07 Feb 2012 07:28:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>按字节截取字符串</title>
		<link>http://www.welefen.com/substr-by-byte.html</link>
		<comments>http://www.welefen.com/substr-by-byte.html#comments</comments>
		<pubDate>Tue, 09 Mar 2010 04:02:58 +0000</pubDate>
		<dc:creator>welefen</dc:creator>
				<category><![CDATA[前端开发]]></category>
		<category><![CDATA[byte]]></category>
		<category><![CDATA[js]]></category>

		<guid isPermaLink="false">http://www.welefen.com/?p=273</guid>
		<description><![CDATA[在JS中，由于中文和英文是同等对待的，但有时候我们希望是一个中文按两个字节算，这就出现了按字节截取字符串的功能。下面列举了 2种实现方式。 循环检测 这种实现方式来自于Tangram，具体实现如下： baidu.string.getByteLength = function (source) { return String(source).replace(/[^\x00-\xff]/g, “ci”).length; }; /* * Tangram * Copyright 2009 Baidu Inc. All rights reserved. * * path: baidu/string/subByte.js * author: dron, erik * version: 1.1.0 * date: 2009/11/30 */ /** * 对目标字符串按gbk编码截取字节长度 * * @param {string} source 目标字符串 * @param {number} length 需要截取的字节长度 * @return [...]]]></description>
		<wfw:commentRss>http://www.welefen.com/substr-by-byte.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using eaccelerator
Database Caching 1/8 queries in 0.005 seconds using disk: basic
Object Caching 317/326 objects using disk: basic

Served from: welefen.com @ 2012-02-08 03:58:57 -->
