Is there any way for a program to find out how many spaces a particular tab '\t' character represents in a file?
I am writing a program for fixing a fairly long file, i.e. lining up the data properly in the third column. I found it necessary to replace all the tab characters found in the file with the number of spaces they represent. I initially assumed they would all be the same in terms of spaces, but I just found out they are not, so I can not make any assumption like "one length fits all" and expect my program to accomplish the job properly. For example, at least one tab character I found in the file represents 3 spaces, and another tab character I looked at represents 5 spaces. Don't ask me why this is, because I just copied/pasted the data in the file from an online source, and I wasn't the one who wrote it to begin with.

So the bottom line is, I'm hoping there's some way to find out programmatically how many spaces each tab represents, so that I can replace the tabs with spaces.

Thanks in advance.