I have a contenteditable element that onblur sends its value to the server.
Since it is contenteditable , with repeated spaces instead of white space, , so the resulting HTML could be:
Testing title middle entry
What when extracted with the .text() element from the element looks like usually spaced (emphasizes spaces):
Testing_title___middle___entry____
This is the .text() value that I am posting to my PHP server. There I look at the save procedure. Since I need a string trimmed, the base trim($title) did not cut.
And, I can't seem to hug him.
I also tried this. How to decode Unicode escape sequences such as "\ u00ed" for valid UTF-8 encoded characters? also did not help.
The Chrome Network Inspector shows what it sends on this encoded data:
Testing+title+%C2%A0+middle+%C2%A0+entry+%C2%A0+%C2%A0
implode(', ', unpack('C*', $title)) returns:
84, 101, 115, 116, 105, 110, 103, // Testing 32, // space 116, 105, 116, 108, 101, // title 32, 194, 160, // 32, 109, 105, 100, 100, 108, 101, // middle 32, 194, 160, 32, 101, 110, 116, 114, 121, // entry 32, 194, 160, 32, 194, 160
$title is ultimately just a $_POST['title'] .
How to trim all spaces from this line?
FINALLY, THE DECISION WAS:
$title = preg_replace('/\s/iu', ' ', $title)