JavaScript замените пробелы на NBSP
str = str.replace(/\s/g, " ");
Friendly Hawk
str = str.replace(/\s/g, " ");