Text cut off on save

I am using WP 3.4. My problem occurs when I attempt to copy and paste anything into the post or page editor of WordPress. The situation arises every time I save or attempt to preview the post. The post gets truncated and about 65% of the text gets chopped off the end of the post. This does not happen if I manually enter content into the text box and then preview or save it.

This works well on my other WP site but not this new install. I have used text editors to strip out formatting. I have also used the text editor copy and paste feature within WordPress but nothing works.

Here’s some background. I first installed WordPress 3.4 through Bluehost. That’s when I discovered the problem. I then reinstalled WP through BlueHost. This did nothing to resolve the issue. I then downloaded WordPress and uploaded it to BlueHost but the problem still exists.

I tried using the 20/10 theme. Then I tried using the Genesis Framework theme. I also tried using the Genesis Framework with the Prose child theme. The problem would occur each and every time. I should note here that all plugins are turned off while attempting to create a post.

I did not link to the site as it is under construction and the only post available was manually entered into the text editor and saved which does not cause a problem.

Here is an example of what happens. I copy this text into the text box.

I have been involved in Local SEO long enough to remember my old friend the Local Business Center. This service offered free business listing similar to a local directory site. I thought what a great idea.
The fact that these listings were being featured by Google for local searches made them extremely useful. If your local website was having problems, ranking in the organic results this was a godsend.
In the early days just claiming or setting up a listing got your business onto the first page of the Google results. It was often a one and done situation for many small business owners.
With little or no effort, you could easily land on the first page of the Google results in most markets. Moreover, this wasn’t always true for many websites trying to get onto Google results front page.

(for the full text see revision history)

This is what is left after I save or preview it.

“I have been involved in Local SEO long enough to remember my old friend the Local Business Center. This service offered free business listing similar to a local directory site. I thought what a great idea.
The fact that these listings were being featured by Google for local searches made them extremely useful. If your local website was having problems, ranking in the organic results this was a godsend.
In the early days just claiming or setting up a listing got your business onto the first page of the Google results. It was often a one and done situation for many small business owners.
With little or no effort, you could easily land on the first page of the Google results in most markets. Moreover, this wasn”

It also occurs with much smaller posts as well.

I have been working on this problem for about a week and could use any help available.

Solutions Collecting From Web of "Text cut off on save"

Your browser doesn’t send the copied text UTF-8 encoded to the server. On the first character that isn’t UTF-8 compatible, in your example the apostrophe – ’ –, the stream to the data base is broken and not recovered. That’s a browser issue.
If I had to guess – well, I have because you didn’t mention it – I would say Internet Explorer.

There are two ways to fix that.

  1. Get a better browser.

  2. Make sure everything you try to save is UTF-8 compatible. And here is finally a chance to bring this issue on topic for our site. 🙂

You can filter 'wp_insert_post_data' and prepare all the data. The following code should work as a plugin (not tested, it is just a prototype).

<?php
/* Plugin Name: Force UTF-8 */
add_filter( 'wp_insert_post_data', 'wpse_56411_force_utf8' );

function wpse_56411_force_utf8( $data ) 
{
    $out = array();
    foreach ( $data as $key => $value )
    {
        if ( ! seems_utf8( $value ) )
        {
            if ( function_exists( 'mb_convert_encoding' ) )
            {
                $out[ $key ] = mb_convert_encoding( $value, 'UTF-8', 'windows-1252' );
            }
            elseif ( function_exists( 'iconv' ) )
            {
                $out[ $key ] = iconv( 'windows-1252', 'UTF-8', $value );
            }
            else
            {
                $out[ $key ] = utf8_encode( $value );
            }
        }
        else
        {
            $out[ $key ] = $value;
        }
    }
    return $out;
}

I had the problem just as well, first Umlaut (or in other term: first non-ascii latin1-character aka first invalid unicode character) and things got truncated on save. I am on Firefox 15, not IE.

Root cause: Client requests require me to deliver latin1 and (hence?) work with a latin1 database (aka ISO-8559-1, let’s skip the subtleties).

Fixed in wp-config.php by:

  • define(‘DB_CHARSET’, ‘latin1’); //this one matters mosted
  • define(‘DB_COLLATE’, ‘latin1_swedish_ci’);

Before I did this, I converted my database to latin1 (exporting in phpmyadmin, a bunch of search and replace, re-import). I think, the latter doesn’t matter (though it makes sense to have), the first part does: Invalid unicode (aka latin1) does not like to travel accross a utf8 connection.

The problem is fixed. I had the location setting as UTC 7 for Arizona. When that was changed everything worked. WOW! Thanks for the help!