CKeditor doesn't format the body value I am building a website in Hindi language. I was given a Database containing rows of title and body. I created a node for each row using this code :

$query = db_select('hindi', 'n')
      -&gt;fields('n', array('title','body'))
      -&gt;execute();

foreach($query as $item) {
    $title = $item-&gt;title;
    $body = $item-&gt;body_value;
    $values = array(
        'type' =&gt; 'article',
        'uid' =&gt; 1,
        'status' =&gt; 1,
        'comment' =&gt; 0,
        'promote' =&gt; 0,
        'language'  =&gt; 'hi'
    );
    $entity = entity_create ('node', $values);
    $ewrapper = entity_metadata_wrapper('node', $entity);
    $ewrapper-&gt;title-&gt;set($title);      
    $ewrapper-&gt;field_body-&gt;set(array('value' =&gt; $body,'format'=&gt;'full_html'));
    $ewrapper-&gt;save();
}


The nodes are display very well in the node view page, like this



But Ckeditor  doesn't perform the text formats (line breaks and ...). Like this



What is the problem?



More information

This is the result of Firebug when inspecting the Body value of the CKEditor
According to my experience &lt;br&gt; causes this problem ,my solution for this is to replace all &lt;br&gt; with &lt;br /&gt;  before saving in body field 

So try 

$body =   str_replace("&lt;br\s*&gt;", "&lt;br /&gt;",nl2br($item-&gt;body_value));