I'm trying to save some simple PHP objects using RedBeanPHP. It works fine, except that on string fields, it reaches a point where there is an accented vowel, ie á
or 'í' and just skips the rest of the remaining characters in the string.
Example:
// Actual string in PHP script.
Esta es una frase mía y me gusta!
// Saved to database.
Esta es una frase m
Here's my PHP script:
// Setup RedBean to work with a database.
R::setup('mysql:host=localhost;dbname=noticias','root','');
foreach($parsedNews as &$tmpNews) {
$noticia = R::dispense('noticia');
$noticia->imagen = $tmpNews->get_image();
$noticia->fecha = $tmpNews->get_fechanoticia();
$noticia->titulo = $tmpNews->get_title();
$noticia->url = $tmpNews->get_sourceurl();
$noticia->descripcion = $tmpNews->get_description();
$id = R::store($noticia);
}
Set your database table collations to UTF-8. (utf8-unicode-ci is probably what you want).
I think the correct answer is that the source encoding is not actually UTF8.
$bean->property = iconv("ISO-8859-1", "UTF-8", "Esta es una frase mía y me gusta!");