Remove double space after a period

I cannot offer a JavaScript solution, because I am not sure where exactly this is happening.

But … we can hook into wp_insert_post_data and solve this issue in PHP:

add_filter( 'wp_insert_post_data', 't5_strip_double_spaces', 20 );

function t5_strip_double_spaces( $data )
{
    $data['post_content'] = preg_replace(
        "~( \x{C2}\x{A0}|\x{C2}\x{A0} )~m",
        ' ',
        $data['post_content']
    );
    return $data;
}

As plugin on GitHub.

error code: 523