Soft hyphen

In computing and typesetting, a soft hyphen (Unicode ) or syllable hyphen, is a code point reserved in some coded character sets for the purpose of breaking words across lines by inserting visible hyphens if they fall on the line end but remain invisible within the line.

Two alternative ways of using the soft hyphen character for this purpose have emerged, depending on whether the encoded text will be broken into lines by its recipient, or has already been preformatted by its originator.

Text to be formatted by the recipient
The use of SHY characters in text that will be broken into lines by the recipient is the application context considered by the post-1999 HTML and Unicode specifications, as well as some word-processing file formats. In this context, the soft hyphen may also be called a discretionary hyphen or optional hyphen. It serves as an invisible marker used to specify a place in text where a hyphenated break is allowed without forcing a line break in an inconvenient place if the text is re-flowed. It becomes visible only after word wrapping at the end of a line. The soft hyphen's Unicode semantics and HTML implementation are in many ways similar to Unicode's zero-width space, with the exception that the soft hyphen will preserve the kerning of the characters on either side when not visible. The zero-width space, on the other hand, will not, as it is considered a visible character even if not rendered, thus having its own kerning metrics.

To show the effect of a soft hyphen in HTML, the words of the following text (from the poem Spring and Fall by Gerard Manley Hopkins) have been separated with soft hyphens: Margaret&shy;Are&shy;You&shy;Grieving&shy;Over&shy;Goldengrove&shy;Unleaving&shy;Leaves&shy;Like&shy;The&shy;Things&shy;Of&shy;Man&shy;You&shy;With&shy;Your&shy;Fresh&shy;Thoughts&shy;Care&shy;For&shy;Can&shy;You&shy;Ah&shy;As&shy;The&shy;Heart&shy;Grows&shy;Older&shy;It&shy;Will&shy;Come&shy;To&shy;Such&shy;Sights&shy;Colder&shy;By&shy;And&shy;By&shy;Nor&shy;Spare&shy;A&shy;Sigh&shy;Though&shy;Worlds&shy;Of&shy;Wanwood&shy;Leafmeal&shy;Lie&shy;And&shy;Yet&shy;You&shy;Will&shy;Weep&shy;And&shy;Know&shy;Why&shy;Now&shy;No&shy;Matter&shy;Child&shy;The&shy;Name&shy;Sorrows&shy;Springs&shy;Are&shy;The&shy;Same&shy;Nor&shy;Mouth&shy;Had&shy;No&shy;Nor&shy;Mind&shy;Expressed&shy;What&shy;Heart&shy;Heard&shy;Of&shy;Ghost&shy;Guessed&shy;It&shy;Is&shy;The&shy;Blight&shy;Man&shy;Was&shy;Born&shy;For&shy;It&shy;Is&shy;Margaret&shy;You&shy;Mourn&shy;For On HTML browsers supporting soft hyphens, resizing the window will re-break the above text only at word boundaries, and insert a hyphen at the end of each line.

Text preformatted by the originator
The SHY character is also used in text where paragraphs have already been broken into lines, such as certain plain text files, text sent to VT100-style terminal emulators or printers, or pages represented in page description languages. This is the application context originally considered by the EBCDIC and ISO 8859-1 standards and implemented in many VT100 terminal emulators.

Here, SHY is a visible hyphen that is usually visually indistinguishable from a regular hyphen, but has been inserted solely for the purpose of line breaking. The purpose of the soft hyphen here is to distinguish it from any regular hyphen that might have been part of the original spelling of the word. This distinction helps re-use of already formatted text, when line breaks and soft hyphens inserted during word wrapping have to be removed to convert the text back into its unformatted form. For example, the copy or paste function of a terminal emulator can offer to replace line breaks with a space character, and remove any soft hyphens including any immediately following whitespace characters.

An example application that outputs soft hyphens for this reason is the groff text formatter as used on many Unix/Linux systems to display man pages.

Encodings and definitions
Soft hyphen (SHY) characters in coded characters sets, roughly in chronological order:
 * EBCDIC placed a SHY character (known there as a "syllable hyphen") at position 202 (0xCA hexadecimal). IBM defined its purpose as a "hyphen used to divide a word at the end of a line [that] may be removed when a program adjusts lines."
 * German standard DIN 31626 defined a C1 control code set defining 0x8D as an "Optional Syllabification Control (OSC)", a "print control character" for use marking syllable boundaries in long words. This C1 control set was registered in 1979. (Note: this is not the same as the ISO/IEC 6429 C1 control code .)
 * ISO 8859-1:1986 (Latin 1) inherited SHY from EBCDIC, but called it "soft hyphen", placed it at position 0xAD (hexadecimal), and stated its purpose as "for use when a line break has been established within a word". Other ISO 8859 parts placed it at the same position, with the exception of ISO 8859-11 (Latin/Thai), which lacks it.
 * IBM code page 850 (an MS-DOS character set covering all ISO 8859-1 characters) placed it at position 240 = 0xF0.
 * SGML's "Numeric and Special Graphic" (isonum) character entity set (ISO 8879:1986) includes  for the ISO 8859-1 soft hyphen.
 * Unicode 1.0 (1991) and ISO 10646 (1993) took the first 256 code positions from ISO 8859-1, resulting in SHY at Unicode code point of U+00AD.
 * HTML 2 (1995) incorporated the "&amp;shy;" character entity from SGML, but explicitly discouraged its use.
 * HTML 4 (1999) redefined the purpose of the character as marking a hyphenation opportunity, which only becomes visible as a hyphen at the end of a line after formatting.
 * Unicode 4.0 (2002) changed the category of its SHY character from previously "Pd" (punctuation, dash) to "Cf" (other, format), thereby aligning its interpretation of the character with that of HTML 4.

Other commands for marking hyphenation opportunities in text formatting languages (similar to the HTML 4 and Unicode 4.0 interpretation of SHY):
 * troff and groff:.
 * TeX and LaTeX:

Security issues
Soft hyphens, like other invisible characters, have been used to obscure malicious domains or URLs in e-mail spam.

They are also used in emails to try to defeat spam prevention systems. For example, the phrase "I need your assista&shy;nce discreetly" has a soft hyphen in the word assistance which may mean a mail system would not detect the phrase in the email body.