I wrote a PHP script which gets a text input as input from a page. The code is only this, for now:
<?php
include("../Includes/Database.php");
mysql_select_db('...', $db3);
$originalText=$_POST['text'];
echo $originalText;
?>
The code works fine for normal input (printable ASCII), but not for special characters such as é, д, φ… For example, inputting Stack Overflow outputs Stack Overflow, while Δημοκρατία returns ΔημοκÏατία. It doesn’t work for Extended ASCII, either: même returns même.
I don’t need full Unicode support [although it’d be good], just extended ASCII, as the input text will be in Italian (which uses à, è, é, ì, ò and ù).
[Exactly, Δημοκρατία uses Unicode characters, as it is Greek for “democracy”; même uses Extended ASCII, as it is French for “same” (ê is Extended ASCII)]
A good way to achieve this is declaring the encoding of the page, either modifying the HTTP header or using a
<meta>tag. In this case, theUTF-8encoding will fit the requirements.HTTP header:
HTML (will be overridden by the HTTP header):