Welcome Guest, Not a member yet? Register   Sign In
Posting form htmlentities
#1

[eluser]Clooner[/eluser]
I'm trying to wrap my head around this but I don't seem to grasp the concept.

Input from a form (utf-8) on a html 5(utf-8) page gets posted to a ci project (utf-8) then when I insert an & symbol it get's posted correctly and I encode the html entities so I can show them on my website. Then if I do exactly the same thing with an currency symbol e.g. € the input get's deleted!. I found the input get's deleted in the utf-8 class(uni) in the function clean_string. Now I'm thinking my input is crooked. How can I make sure I post using utf-8?

form and html header code
Code:
<!DOCTYPE HTML>
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Title goes here!&lt;/title&gt;
    &lt;meta charset="UTF-8" /&gt;

Code:
&lt;form action="http://localhost/edit/1" method="post" accept-charset="utf-8" id="edit_form"&gt;
#2

[eluser]Clooner[/eluser]
I found that the problem is in this function in the utf8.php file.
Code:
function clean_string($str)
    {
        if ($this->_is_ascii($str) === FALSE)
        {
            $str = @iconv('UTF-8', 'UTF-8//IGNORE', $str);
        }

        return $str;
    }
What I don't understand is that when I input an UTF-8 string with a currency sign(EURO) in it is doesn't return anything. This is also not as how it should work. Because of the //IGNORE tag it should ignore the errors and return the known characters.

What am I overlooking or is the iconv just broken?
#3

[eluser]InsiteFX[/eluser]
Try it without using html entities and see if it works.

InsiteFX
#4

[eluser]Clooner[/eluser]
The problem is even before htmlentities when the post input gets cleaned. the title is a bit misleading, it has nothing to do with htmlentities...
#5

[eluser]InsiteFX[/eluser]
Well I think this is the problem, this is from php.net iconv
Code:
&lt;?php
$text = "This is the Euro symbol '€'.";

echo 'Original : ', $text, PHP_EOL;
echo 'TRANSLIT : ', iconv("UTF-8", "ISO-8859-1//TRANSLIT", $text), PHP_EOL;
echo 'IGNORE   : ', iconv("UTF-8", "ISO-8859-1//IGNORE", $text), PHP_EOL;
echo 'Plain    : ', iconv("UTF-8", "ISO-8859-1", $text), PHP_EOL;
?&gt;

// Displays
Original : This is the Euro symbol '€'.
TRANSLIT : This is the Euro symbol 'EUR'.
IGNORE   : This is the Euro symbol ''.
Plain    :
Notice: iconv(): Detected an illegal character in input string in .\iconv-example.php on line 7
This is the Euro symbol '
I think this needs to be reported to the Reactor Team!

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB