700 Software
700 Software

Reputation: 87833

Strike through plain text with unicode characters?

Is it possible to strike through unwanted revised words in your code comments? Since developers still code in the dark ages a simpler time of plain text where text cannot be formatted using hidden identifiers, the only way to accomplish this is with Unicode Characters.

Since some unicode characters can extend be̜̤͉̘̝̙͂̓ͫ̽̊̀y̐ͨͧͩ̚o̥̗̞̬̯͚͂n͔͖̤̜̖̪͒̈́ͅd̯̮ͭ their designated boundaries, I thought it might be possible to find a Unicode Character that creates the strike through effect.

Unfortunately dash characters — occupy a significant amount of horizontal space. Is there an alternative character that I can use to create the strike-through effect across my text?

Upvotes: 30

Views: 21138

Answers (3)

Caridorc
Caridorc

Reputation: 6661

You can also use this function in Python 3 to generate it on the fly:

def striken(text):
    return ''.join(t+chr(822) for t in text)

Example output:

>>> def striken(text):
...     return ''.join(t+chr(822) for t in text)
... 
>>> striken("hello")
'h̶e̶l̶l̶o̶'
>>> striken("hello darkness my old friend")
'h̶e̶l̶l̶o̶ ̶d̶a̶r̶k̶n̶e̶s̶s̶ ̶m̶y̶ ̶o̶l̶d̶ ̶f̶r̶i̶e̶n̶d̶'

Also you may use:

def striken(text):
    return '\u0336'.join(text) + '\u0336'

to be faster if your text is really long, as suggested by @astroMonkey.

Upvotes: 8

Frank N
Frank N

Reputation: 10396

in an AutoHotkey script:

<^>!ü::Send {U+0336}

pressing

AltGr+ü , y , AltGr+ü , e , AltGr+ü , s

̶y̶e̶s, I can strikethrough 😬

(sorry, I chose German umlaut for shortcut, you probably want some other key)

Upvotes: 0

user2357112
user2357112

Reputation: 281585

There's U+0336, COMBINING LONG STROKE OVERLAY. Googling Unicode strikethough turns up tools to apply it to your text, such as this one. Whether it looks any good will depend on your font; it looks pretty terrible on my environment.

Upvotes: 29

Related Questions