Joe Kuhn
Well-known member
I'm working on a project for another member who has a site with tab delimited data in posts. He's got alignment problems, so I've offered to give him a hand at straightening out the columns for his forum members.
The key for me has been to understand that the tab character is used as a delimiter between fields. That means there are no space characters in the source data between data elements, just tab characters, as in:
Data1[tab]Data2[tab]Data3[CR][LF]
The website view-char shows this nicely after creating the above data line in a text editor that honors tab characters like Windows Notepad, pasting the line into the website and hitting 'Show me the characters' button. Note that even their editor won't let you type a tab character in the middle of some text so you have to do it in another app and paste it in, then hit the show-me button. They show the tab character as a right arrow.
If you're going to replace the tab character with spaces and keep the alignment the same, you need to add the correct number of spaces to fill out the field.
Suppose your fields are 8 characters long max. If a field is filled with 5 characters as above you need to add 3 spaces to keep the spacing the same when switching from tabs to spaces. Let's demonstrate with a second line of data that's filled differently. To keep the second row below in line with the first, you need to add 4 spaces after "Dat4" and 2 spaces after 'Data5'.
Here it is in view-char with tab characters replaced with spaces, shown as dots:
Notice that both the before and after windows above are aligned correctly. The area where you paste the string and the "Show me the characters" result are both aligned column-wise. That's the goal. Many editors simply replace tab characters with x number of spaces which will put the alignment out of whack (and they eat extra spaces). You can see that here in the second column below. The third column is aligned because of the extra character in "Data5".
Data1 Data2 Data3
Dat4 Data_5 Data6
More later.
The key for me has been to understand that the tab character is used as a delimiter between fields. That means there are no space characters in the source data between data elements, just tab characters, as in:
Data1[tab]Data2[tab]Data3[CR][LF]
The website view-char shows this nicely after creating the above data line in a text editor that honors tab characters like Windows Notepad, pasting the line into the website and hitting 'Show me the characters' button. Note that even their editor won't let you type a tab character in the middle of some text so you have to do it in another app and paste it in, then hit the show-me button. They show the tab character as a right arrow.
If you're going to replace the tab character with spaces and keep the alignment the same, you need to add the correct number of spaces to fill out the field.
Suppose your fields are 8 characters long max. If a field is filled with 5 characters as above you need to add 3 spaces to keep the spacing the same when switching from tabs to spaces. Let's demonstrate with a second line of data that's filled differently. To keep the second row below in line with the first, you need to add 4 spaces after "Dat4" and 2 spaces after 'Data5'.
Here it is in view-char with tab characters replaced with spaces, shown as dots:
Notice that both the before and after windows above are aligned correctly. The area where you paste the string and the "Show me the characters" result are both aligned column-wise. That's the goal. Many editors simply replace tab characters with x number of spaces which will put the alignment out of whack (and they eat extra spaces). You can see that here in the second column below. The third column is aligned because of the extra character in "Data5".
Data1 Data2 Data3
Dat4 Data_5 Data6
More later.
Last edited: