Hi epvp!
Ich habe in PHP einen String,
die Unicode/Ascii-reprsentation des Strings ist
Code:
71|119|117|106|119|162|77|125|123|112|125|168|83|402|129|118|402|174
Nun wird der Array des Ascii/Unicode Codes in einen String umgewandelt, was auch funktioniert. Dieser String wird jetzt wieder in seine Uicode/Ascii-reprsentation umgewandelt, jedoch ist diese
nicht identisch mit dem Code oben.
Hier mein Code:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
function unichr($intval) {
return mb_convert_encoding(pack('n', $intval), 'UTF-8', 'UTF-16BE');
}
function uniord($c) {
if (strlen($c) == 1) {
return ord($c);
}
$h = ord($c
{
0});
if ($h <= 0x7F) {
return $h;
} else
if ($h < 0xC2) {
return false;
} else
if ($h <= 0xDF) {
return ($h & 0x1F) << 6 | (ord($c{1}) & 0x3F);
} else
if ($h <= 0xEF) {
return ($h & 0x0F) << 12 | (ord($c{1}) & 0x3F) << 6 | (ord($c{2}) & 0x3F);
} else
if ($h <= 0xF4) {
return ($h & 0x0F) << 18 | (ord($c{1}) & 0x3F) << 12 | (ord($c{2}) & 0x3F) << 6 | (ord($c{3}) & 0x3F);
} else {
return false;
}
}
$test = explode("|", "71|119|117|106|119|162|77|125|123|112|125|168|83| 402|129|118|402|174");
echo "GwujwM}{p}Sv = \"71|119|117|106|119|162|77|125|123|112|125|168|83 |402|129|118|402|174\"<br>";
$string = "";
foreach ($test as $value) {
$string .= unichr($value);
};
echo "71|119|117|106|119|162|77|125|123|112|125|168|83| 402|129|118|402|174 = $string<br>";
$string2 = "";
$test = str_split($string);
foreach ($test as $value) {
$string2.= uniord($value) . "|";
}
echo "$string = $string2";
?>
</body>
</html>
Die Ausgabe des Codes
Code:
GwujwM}{p}Sv = "[COLOR="Green"]71|119|117|106|119|162|77|125|123|112|125|168|83|402|129|118|402|174[/COLOR]"
71|119|117|106|119|162|77|125|123|112|125|168|83|402|129|118|402|174 = GwujwM}{p}Sv
GwujwM}{p}Sv = [SIZE="5"]71|119|117|106|119|194|162|77|125|123|112|125|194|168|83|198|146|194|129|118|198|146|194|174[/SIZE]|
So sollte es eigentlich aussehen:
Code:
GwujwM}{p}Sv = "[COLOR="Green"]71|119|117|106|119|162|77|125|123|112|125|168|83|402|129|118|402|174[/COLOR]"
71|119|117|106|119|162|77|125|123|112|125|168|83|402|129|118|402|174 = GwujwM}{p}Sv
GwujwM}{p}Sv =
[SIZE="5"]]71|119|117|106|119|162|77|125|123|112|125|168|83|402|129|118|402|174[/SIZE]|
Was ist da los?
MfG