php-i18n Digest 21 Mar 2009 22:35:48 -0000 Issue 422
Topics (messages 1313 through 1316):
mb_check_encoding
1313 by: Giacomo Mazzocato
1314 by: Giacomo Mazzocato
1315 by: Giacomo Mazzocato
problem with utf8_encode
1316 by: Valkum
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Hi,
I'm having some problems with mb_check_encoding.
When it's invoked without parameters does it check
all the REQUEST variables to see if their values have the same
encoding
as mb_internal_encoding() ? (This is what I understood from the
manual)
As far as I know that doesn't happen.
Here's an example file :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Help needed</title>
<meta http-equiv="Content-Type" content=
"text/html; charset=utf-8" />
</head>
<body>
<form action="?" method="post">
<input type="text" name="foo" value="" />
<input type="submit" value="submit" />
</form>
<?php
mb_internal_encoding("UTF-8");
var_dump($_REQUEST) ;
echo "<p>" ;
if (mb_check_encoding()) {
echo "request encoding ok" ;
} else {
echo "request encoding not ok" ;
}
echo "</p>" ;
?>
</body>
</html>
If you post the value from your browser, all is ok because the
encoding of the page is recognized by the browser as utf-8 (I think).
But if I call that page with curl simulating an Invalid encoding
attack,
I get the same result(request encoding ok) while I should get request encoding
not ok.
Here's the command I used :
curl --data-urlencode $'foo=prov\xef'
http://localhost/mine/test/encoding.php
Thank you in advance
Bye,
Giacomo
--- End Message ---
--- Begin Message ---
Hi,
I'm having some problems with mb_check_encoding.
When it's invoked without parameters does it check
all the REQUEST variables to see if their values have the same
encoding
as mb_internal_encoding() ? (This is what I understood from the
manual)
As far as I know that doesn't happen.
Here's an example file :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Help needed</title>
<meta http-equiv="Content-Type" content=
"text/html; charset=utf-8" />
</head>
<body>
<form action="?" method="post">
<input type="text" name="foo" value="" />
<input type="submit" value="submit" />
</form>
<?php
mb_internal_encoding("UTF-8");
var_dump($_REQUEST) ;
echo "<p>" ;
if (mb_check_encoding()) {
echo "request encoding ok" ;
} else {
echo "request encoding not ok" ;
}
echo "</p>" ;
?>
</body>
</html>
If you post the value from your browser, all is ok because the
encoding of the page is recognized by the browser as utf-8 (I think).
But if I call that page with curl simulating an Invalid encoding
attack,
I get the same result(request encoding ok).
Here's the command I used :
curl --data-urlencode $'foo=prov\xef'
http://localhost/mine/test/encoding.php
Thank you in advance
Bye,
Giacomo
--- End Message ---
--- Begin Message ---
Hi,
I'm having some problems with mb_check_encoding.
When it's invoked without parameters does it check
all the REQUEST variables to see if their values have the same
encoding
as mb_internal_encoding() ? (This is what I understood from the
manual)
As far as I know that doesn't happen.
Here's an example file :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Help needed</title>
<meta http-equiv="Content-Type" content=
"text/html; charset=utf-8" />
</head>
<body>
<form action="?" method="post">
<input type="text" name="foo" value="" />
<input type="submit" value="submit" />
</form>
<?php
mb_internal_encoding("UTF-8");
var_dump($_REQUEST) ;
echo "<p>" ;
if (mb_check_encoding()) {
echo "request encoding ok" ;
} else {
echo "request encoding not ok" ;
}
echo "</p>" ;
?>
</body>
</html>
If you post the value from your browser, all is ok because the
encoding of the page is recognized by the browser as utf-8 (I think).
But if I call that page with curl simulating an Invalid encoding
attack,
I get the same result(request encoding ok) but I should get request
encoding not ok
Here's the command I used :
curl --data-urlencode $'foo=prov\xef'
http://localhost/mine/test/encoding.php
Thank you in advance
Bye,
Giacomo
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
--- End Message ---
--- Begin Message ---
Hello,
i have a big problem.
When i try to encode a big string to utf8 i got a core dump
her is my code.
<?php
function is_utf8($string) {
// From http://w3.org/International/questions/qa-forms-utf-8.html
return preg_match('%^(?:
[\x09\x0A\x0D\x20-\x7E] # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
)*$%xs', $string);
}
function output($string)
{
if(!is_utf8($string))
$string = utf8_encode($string);
return addslashes($string);
}
$string = <<<EOH
<div align="justify">
<p>- Im Aufbau -</p>
<h3 id="aventurien">Aventurien</h3>
<div style="border: 1px none ; margin: 5px 5px 5px 10px; float:
right; width: 100px;"><strong>Navigation</strong> <br />
<br />
<a href="#aventurien">Aventurien</a><br />
<a href="#ferdok">Die Stadt Ferdok</a><br />
<a href="#weitere">Weitere Ziele</a></div>
<p>{mosimage} Aventurien ist ein Kontinent der Welt Dere und
Ausgangspunkt für die meisten Abenteuer in der Welt von <em>Das
Schwarze Auge</em>. Von Nord nach Süd erstreckt sich der
Kontinent ca. über 3000 Meilen, von Ost nach West sind es
immerhin noch 2000 Meilen. Von den Tundren Thorwals bis zur
Wüste Khom kann man so ziemlich alle Klimazonen in Aventurien
finden.</p>
<p>Im Herzen Aventuriens liegt das Kaiserreich, auch das Mittelreich
genannt, mit seiner Hauptstadt Gareth (rot umrandeter Bereich). Die
Kultur erinnert entfernt an das mittelalterliche Europa. Die
Handlung Drakensangs wird zu großen Teilen im Mittelreich
spielen, genauer gesagt, in der Umgebung der Stadt Ferdok (s.u.).
Doch auch andere, exotischere Orte sollen Ziel der Reise werden.</p>
<p>Zahlreiche Völker und Rassen bewohnen den Kontinent, allen
voran natürlich die Menschenvölker, die die Mehrheit der
Bewohner stellen. Unter den Menschen gibt es zahlreiche
unterschiedliche Kulturen, z. B. die wikingerähnlichen
Thorwaler, das Nomadenvolk der Nivesen oder eben die
Mittelländer. Daneben gibt es natürlich noch
fantastischere Völker wie die Elfen (mit mehrern Untergruppen),
Zwerge, Orks und mehr, eben alles, was eine Fantasywelt zu bieten
hat.</p>
<p> </p>
<h3 id="ferdok">Ferdok</h3>
<p><a target="_blank" href="images/stories/stadtplan_g.jpg">
{mosimage}</a></p>
<p>Ferdok ist eine Grafenstadt im Mittelreich, etwas westlich der
Hauptstadt Gareth, und hat etwa 3000 Einwohner. Sie gehört zu
den ältesten menschlichen Siedlungen des Kosch. Im Laufe der
Geschichte mußte die Stadt jedoch wegen einer Änderung
des Flußlaufes des Großen Flußes im Jahre 270 BF
verlegt werden, da die Stadt in der Bedeutungslosigkeit zu versinken
drohte. Heute liegt Ferdok wieder direkt an der Einmündung des
Rakula in den Großen Fluß. Obwohl die Stadt die
frühere Bedeutung längst verloren hat, hat sich Ferdok als
ein wichtiger Handelshafen etabliert (weltberühmt: Ferdoker
Bier). Hier werden die Waren von Gareth umgeschlagen, die über
die große Handelsstraße von und nach Ferdok verfrachtet
werden. Ferdok ist damit eines der Tore zum Westen und
ermöglicht schnelle Reisen in andere Teile der Aventuriens.</p>
<p>Verwaltungstechnisch gehört Ferdok zum Fürstentum
Kosch, dessen Hauptstadt sie langezeit war. Mittlerweile hat sie
diesen Status jedoch an Angbar verloren. Trotz seiner wichtigen
Rolle als Handelsort sind die Bewohner Ferdoks ein eher biederes
Völkchen und hängen der Erinnerung an die ruhmreichere
Vergangenheit hinterher. Nachts muss man auf den Straßen
neuerdings aufpassen. Zur Handlungszeit verunsichert nämlich
eine grauenhafte Mordserie die Bewohner Ferdoks und lässt die
Bevölkerung nachts nicht richtig schlafen. Einige Bereiche
sollte man dann grundsätzlich nicht mehr besuchen, wenn einem
die eigene Gesundheit am Herzen liegt.</p>
<p>Die Stadt wird eine zentrale Anlaufstelle in Drakensang sein,
weswegen sie auch vollständig, nach den Vorgaben des
DSA-Regelwerks in das Spiel eingebaut wird. Der Stadtplan (zum
Vergrößern anklicken) wurde von Radon Labs dem Regelwerk
direkt entnommen und wird Euch auch für Drakensang gute Dienste
leisten.</p>
<br />
<h3 id="weitere">Weitere Reiseziele des Spiels</h3>
<a target="_blank"
href="images/stories/artikel/map.jpg">{mosimage}</a> Insgesamt soll
es 12 Hauptregionen geben, die jeweils ca. 1 Quadratkilometer
groß sind. Alle diese Regionen unterteilen sich nochmal in
über 50 kleinere Gebiete. Bekannt sind neben Ferdok bislang:
<ul>
<li>Avestreu (kleines Dorf südöstl. von Ferdok)</li>
<li>Dunkelwald (südl. von Ferdok)</li>
<li>Ruine Blutberge (südl. von Ferdok, am Rand des
Dunkelwaldes)</li>
<li>Moorbrück (südl. des Dunkelwaldes)</li>
<li>Burg Grimmzahn (westl. von Moorbrück)</li>
<li>Murolosch (eine Zwergenstadt)</li>
<li>der Berg Drachensang / Drakensang (im Amboss-Gebirge
gelegen)</li>
</ul>
<p> </p>
<p> </p>
<p>Ausführlichere Infos:</p>
<p><a title="Wiki Aventurica" target="_blank"
href="http://dsa4.de/wiki">Wiki Aventurica </a>(externer Link)<br />
<a href="http://www.eychgras.de/koschwiki/index.php"
target="_blank">KoschWiki</a> (externer Link)</p>
<p> </p>
</div>
EOH;
print_r(output($string));
?>
Please help me. When i delete some code from <ul> to </div> at the end,
i get no core dump. only with the full text.
What is the problem??
Greetz Valkum
--- End Message ---