Back to -> BoHu.Net - eNet's website :: This.My.Life

EMail 地址转 Ascii -- 将EMail地址转换为Ascii



PHP:

test@bohu.org
test@bohu.org


PHP code:

<?php
	$result=array();
	for($i=0,$l=mb_strlen($email,'utf-8');$i<$l;++$i){
			$result[]="&amp;#".uniord(mb_substr($email,$i,1,'utf-8'));
	}
	echo "<pre>".join(";",$result).";</pre>";
?>


JavaScript:

test@bohu.org


JS code:

<script type="text/javascript">
	var s = "<?php echo $email;?>";
	var as = "";
	for(var a = 0; a<s.length; a++){
			 as += "&amp;#"+s.charCodeAt(a)+";";
	 }
	document.write("<pre>"+as+"</pre>");
</script>




完整PHP代码:

email2ascii.txt -- 右键另存下载