Kevin
Kevin

Reputation: 413

Horizontal Tab in Unicode

I have a function which stores a string that has read off a StreamReader. The file in question contains horizontal tabs, which I know are registered as U+0009 in Unicode. I'd like to display the string in HTML, which involves some conversion obviously.

The code I've used to attempt this conversion is

readResults = readResults.Replace(ChrW(&H9), "	")

Unfortunately, no love. The tab is removed as is expected of any whitespace characters left undealt with. Any ideas?

EDIT: Figured it out

readResults = readResults.Replace(vbTab, "<pre>&#09;</pre>")

Upvotes: 1

Views: 3515

Answers (1)

Rob W
Rob W

Reputation: 349032

Add the white-space:pre-wrap CSS property to your HTML element. This property will force all white-space (including tabs) to appear. When you also want to preserve newlines, use white-space:pre.

Upvotes: 2

Related Questions