3

我正在尝试使用 RedBeanPHP 保存一些简单的 PHP 对象。它工作得很好,除了在字符串字段上,它到达一个有重音元音的点,即á或'í',并跳过字符串中其余的剩余字符。

例子:

// Actual string in PHP script.
Esta es una frase mía y me gusta!

// Saved to database.
Esta es una frase m

这是我的 PHP 脚本:

// 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);  
}
4

2 回答 2

1

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!");    
于 2014-08-02T05:54:28.227 回答
0

Set your database table collations to UTF-8. (utf8-unicode-ci is probably what you want).

于 2012-07-27T20:25:28.290 回答