zero-width space character ​

  Uncategorized

The zero-width space (ZWSP) is a non-printing character used in computerized typesetting to indicate word boundaries to text processing systems when using scripts that do not use explicit spacing, or after characters (such as the slash) that are not followed by a visible space but after which there may nevertheless be a line break. Normally, it is not a visible separation, but it may expand in passages that are fully justified.

The zero-width space character is very useful for html layout and controlling word wrapping in case of long words, urls, emails, etc. With the ​ character you have full control over word wrapping within your html pages.

To show the effect of the zero-width space, the following words have been separated with zero-width spaces.

Loremipsumdolorsitametcons​etetursadipscingelitrseddiamnonumy​eirmodtemporinviduntutlabo​reetdoloremagnaaliquyameratsed​diamvoluptuaAtveroeosetaccusame​tjustoduodoloresetearebum​Stetclitakasdgubergrennoseatakimatas​anctusestLoremipsumdolorsitametLoremip​sumdolorsitametconsetetursadipscin​gelitrseddiamnonumyeirmodtemporinviduntutlabor​eetdoloremagnaaliquyameratseddiamv​oluptuaAtveroeosetaccusametjustod​uodoloresetearebumStetclitakasdgubergrenoseat​akimatasanctusestLoremipsumdolorsitamet

To add the zero-width space character to your string you can use the following PHP function. The addZWSP function will split the string into parts of 8 char length.

function addZWSP ($str)
{
// zero-width space character
$zwsp = "​";
$tiles = str_split ($str, 8);
$del = "";
$ret = "";
foreach ($tiles as $tile)
{
$ret .= $del . $tile;
$del = $zwsp;
}
return $ret;
}