Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 615
700 Software Avatar asked Aug 12 '16 21:08

700 Software


People also ask

What characters are Unicode?

Unicode covers all the characters for all the writing systems of the world, modern and ancient. It also includes technical symbols, punctuations, and many other characters used in writing text.

How do I text Unicode?

To insert a Unicode character, type the character code, press ALT, and then press X. For example, to type a dollar symbol ($), type 0024, press ALT, and then press X. For more Unicode character codes, see Unicode character code charts by script.

Is strikethrough a text effect?

Strikethrough is a font effect that causes text to appear as though it is crossed out. For example, this text should have a line through the middle of it. The strikethrough effect may be enabled through font properties if a program supports it, or applied to text on a web page using the HTML or CSS.


2 Answers

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.

like image 103
user2357112 supports Monica Avatar answered Oct 25 '22 13:10

user2357112 supports Monica


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

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

Example output

>>> def striken(text):
...   return ''.join(chr(822)+t 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' + '\u0336'.join(text)

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

like image 45
Caridorc Avatar answered Oct 25 '22 14:10

Caridorc