I have to render some text to a web page. The text is coming from sources outside my control and it is formatted using newlines and tab characters.
New lines (\n)
can be replaced by br
tags, but what about preserving tabs? A brief search reveals there is no way to directly render tab characters in HTML.
replace \t
with
.
Each space you want will be a
As pointed out this isn't completely correct as it only pretends to be a tab as HTML doesn't actually output format a tab as you would expect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With