Location: PHPKode > scripts > Percent Russian Text Encoder > percent-russian-text-encoder/percentEncoder.php
<?php
class percentEncoder {
	static $alphabet=array();
	public static function encode($str) {
		self::$alphabet = array(
		  "&#1040;"=>192,"&#1041;"=>193,"&#1042;"=>194,"&#1043;"=>195,"&#1044;"=>196,"&#1045;"=>197,"&#1046;"=>198,"&#1047;"=>199,"&#1048;"=>200,"&#1049;"=>201,"&#1050;"=>202,"&#1051;"=>203,"&#1052;"=>204,"&#1053;"=>205,"&#1054;"=>206,"&#1055;"=>207,"."=>ord("."),"!"=>ord("!"),"?"=>ord("?"),";"=>ord(":"),";"=>ord(";"),"?"=>ord("?"),
		  "&#1056;"=>208,"&#1057;"=>209,"&#1058;"=>210,"&#1059;"=>211,"&#1060;"=>212,"&#1061;"=>213,"&#1062;"=>214,"&#1063;"=>215,"&#1064;"=>216,"&#1065;"=>217,"&#1066;"=>218,"&#1067;"=>219,"&#1068;"=>220,"&#1069;"=>221,"&#1070;"=>222,"&#1071;"=>223," "=>32,chr(10)=>10,
		  "&#1072;"=>224,"&#1073;"=>225,"&#1074;"=>226,"&#1075;"=>227,"&#1076;"=>228,"&#1077;"=>229,"&#1078;"=>230,"&#1079;"=>231,"&#1080;"=>232,"&#1081;"=>233,"&#1082;"=>234,"&#1083;"=>235,"&#1084;"=>236,"&#1085;"=>237,"&#1086;"=>238,"&#1087;"=>239,","=>ord(","),
		  "&#1088;"=>240,"&#1089;"=>241,"&#1090;"=>242,"&#1091;"=>243,"&#1092;"=>244,"&#1093;"=>245,"&#1094;"=>246,"&#1095;"=>247,"&#1096;"=>248,"&#1097;"=>249,"&#1098;"=>250,"&#1099;"=>251,"&#1100;"=>252,"&#1101;"=>253,"&#1102;"=>254,"&#1103;"=>255,"0"=>ord("0"),"1"=>ord("1"),"2"=>ord("2"),"3"=>ord("3"),"4"=>ord("4"),"5"=>ord("5"),"6"=>ord("6"),"7"=>ord("7"),"8"=>ord("8"),"9"=>ord("9")
		  );
		for($i=0;$i<=208;$i++) {
		 	self::$alphabet[chr($i)]=$i;
		}
		$data='';
		for($i=0;$i<mb_strlen($str,"UTF-8");$i++) {
			$char=mb_substr($str,$i,1,"UTF-8");
			$data.="%".self::toHex(self::getOrd($char));
		}
		return $data;
	}
	private function getOrd($letter) {
		return self::$alphabet[$letter];
	}
	private function toHex($dec=225) {  
		 $hex = array(0,1,2,3,4,5,6,7,8,9,"A","B","C","D","E","F");
		 $second = $dec%16;
		 $first=($dec-$second)/16;
		 return ($hex[$first].$hex[$second]);
	}	
}
Return current item: Percent Russian Text Encoder