PHP Conference Kansai 2025

Voting

: min(six, eight)?
(Example: nine)

The Note You're Voting On

webmaster at chassidus dot ru
19 years ago
//I've also built the same way for hebrew to utf converting

function heb2utf($s) {

for($i=0, $m=strlen($s); $i<$m; $i++) {
$c=ord($s[$i]);
if ($c<=127) {$t.=chr($c); continue; }
if ($c>=224 ) {$t.=chr(215).chr($c-80); continue; }


}
return $t;
}

//Simple unicoder and decoder for hebrew and russian:

function unicode_hebrew($str) {
for ($ii=0;$ii<strlen($str);$ii++) {
$xchr=substr($str,$ii,1);
if (ord($xchr)>223) {
$xchr=ord($xchr)+1264;
$xchr="&#" . $xchr . ";";
}
$encode=$encode . $xchr;

}
return $encode;

}

function unicode_russian($str) {
for ($ii=0;$ii<strlen($str);$ii++) {
$xchr=substr($str,$ii,1);
if (ord($xchr)>191) {
$xchr=ord($xchr)+848;
$xchr="&#" . $xchr . ";";
}
$encode=$encode . $xchr;

}
return $encode;

}

function decode_unicoded_hebrew($str) {
$decode="";

$ar=split("&#",$str);

foreach ($ar as $value ) {

$in1=strpos($value,";"); //end of code

if ($in1>0) {// unicode

$code=substr($value,0,$in1);

if ($code>=1456 and $code<=1514) { //hebrew
$code=$code-1264;
$xchr=chr($code);
} else { //other unicode
$xchr="&#" . $code . ";";
}
$xchr=$xchr . substr($value,$in1+1);
} else //not unicode
$xchr = $value;


$decode=$decode . $xchr;
}
return $decode;
}

function decode_unicoded_russian($str) {
$decode="";

$ar=split("&#",$str);

foreach ($ar as $value ) {

$in1=strpos($value,";"); //end of code

if ($in1>0) {// unicode

$code=substr($value,0,$in1);

if ($code>=1040 and $code<=1103) {
$code=$code-848;
$xchr=chr($code);
} else {
$xchr="&#" . $code . ";";
}
$xchr=$xchr . substr($value,$in1+1);
} else
$xchr = $value;


$decode=$decode . $xchr;
}
return $decode;
}

<< Back to user notes page

To Top