LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   A problem with tabs (http://www.linuxquestions.org/questions/linux-newbie-8/a-problem-with-tabs-878041/)

rmknox 04-30-2011 02:28 PM

A problem with tabs
 
Fedora14

I've written a c program which uses tab characters in the output. Output goes to stdout.

When I run it at the terminal command line - output is tabbbed.

If I direct output to a file (./program > book.txt) , and use "more" to display the file, output is tabbed.

If I send the file to my HP 1020 printer, output is not tabbed. I get a space at the location of each tab character.

If I try to open the file with gedit, gedit refuses to open it and says that it has not been able to detect the character encoding. I try all the obvious choices and it rejects them all.

If I try to open it with notepad, notepad opens it and shows the output as tabbed.

If I display it with od, I see the hex 09 characters in the file.

1) what is happening and why?

2) as I recall there is a utility that lets me change the attributres of a file. I imagine I can correct the encoding, but I dont remember what utility.

3) is there sometihng that i need to do as regards compiler settings to get the file marked correctly?

penguiniator 04-30-2011 04:54 PM

The expand utility will convert tabs to spaces. That may solve the problem with your printer. How Gedit interprets your file encoding depends on what else it contains. Perhaps a better editor will work around the problem. Have you tried opening it in Vim?

rmknox 04-30-2011 07:44 PM

thanks - expand replaced the tab characters with spaces

archtoad6 05-05-2011 02:30 PM

FWIW, pr is more complex & therefore more flexible; & of course harder to use.

W/ the right options it can convert spaces back to tabs. Piped into itself (w/ the right options) it can convert n spaces to tabs, & then the tabs to m spaces.

It does not have:
Quote:

-t, --tabs=LIST
use comma separated list of explicit tab positions

Post 4500, 1.88 ppd


All times are GMT -5. The time now is 05:26 AM.