j******r 发帖数: 201 | 1 The length of a tab can be 2, 4 or 8.
For a string read from a file: "\t\t\t", how could we know what
the length of each '\t' is? | T***B 发帖数: 137 | 2 length of '\t' only depends on the editor/terminal you use to display it.
not sure, though.
【在 j******r 的大作中提到】![](/moin_static193/solenoid/img/up.png) : The length of a tab can be 2, 4 or 8. : For a string read from a file: "\t\t\t", how could we know what : the length of each '\t' is?
| o**v 发帖数: 1662 | 3 u r right 【 在 TFIIB (小明) 的大作中提到: 】 | j******r 发帖数: 201 | 4 actually my question is about parsing.
you can get the line and column number from the parser,
but you can not use subString to get the corresponding strings
because if these are tabs, the column number is not exactly the
position of the character in the string
for example:
"\t\tx=int;"
the column for x could be 8 or 4. but you should use subString(3,4?) to get "x",
but not (8,.)or (4,.).
【在 o**v 的大作中提到】![](/moin_static193/solenoid/img/up.png) : u r right 【 在 TFIIB (小明) 的大作中提到: 】
| T***B 发帖数: 137 | 5 how do you get column number? you mean column number for '\t\t' is
something like 8? that's weird.
"x",
it.
【在 j******r 的大作中提到】![](/moin_static193/solenoid/img/up.png) : actually my question is about parsing. : you can get the line and column number from the parser, : but you can not use subString to get the corresponding strings : because if these are tabs, the column number is not exactly the : position of the character in the string : for example: : "\t\tx=int;" : the column for x could be 8 or 4. but you should use subString(3,4?) to get "x", : but not (8,.)or (4,.).
| j******r 发帖数: 201 | 6 yes
if you have a string "\t\tx", and the length of tab is 4, the parser
i am using (javacc) will tell me the column number of 'x' is 8, not 3.
And the editor will show the column is 8 too.
Anyway, if I want to read a file, and display it in another terminal.
And I want the display is exactly as it is in the original one, i still need
to know the length of each '\t'.
【在 T***B 的大作中提到】![](/moin_static193/solenoid/img/up.png) : how do you get column number? you mean column number for '\t\t' is : something like 8? that's weird. : : "x", : it.
| m******t 发帖数: 2416 | 7 \t by itself does not carry a definitive width, it's up to
whoever reads the file to interpret it - that's actually
*the whole point* of having tabs. 8-)
【在 j******r 的大作中提到】![](/moin_static193/solenoid/img/up.png) : yes : if you have a string "\t\tx", and the length of tab is 4, the parser : i am using (javacc) will tell me the column number of 'x' is 8, not 3. : And the editor will show the column is 8 too. : Anyway, if I want to read a file, and display it in another terminal. : And I want the display is exactly as it is in the original one, i still need : to know the length of each '\t'.
| j******r 发帖数: 201 | 8 So there is no way to show the file exactly the same as in any other terminal?
coz just from the file, you have no way to know the length of the tab.
【在 m******t 的大作中提到】![](/moin_static193/solenoid/img/up.png) : \t by itself does not carry a definitive width, it's up to : whoever reads the file to interpret it - that's actually : *the whole point* of having tabs. 8-)
| c****r 发帖数: 185 | 9 Yes. So you should always avoid using the character tab.
Many editors have the option of replacing tab with spaces,
i.e., when you type the tab key, the editor inserts spaces instead
of the tab character.
terminal?
need
【在 j******r 的大作中提到】![](/moin_static193/solenoid/img/up.png) : So there is no way to show the file exactly the same as in any other terminal? : coz just from the file, you have no way to know the length of the tab.
| e***g 发帖数: 158 | 10 death to tabs
【在 c****r 的大作中提到】![](/moin_static193/solenoid/img/up.png) : Yes. So you should always avoid using the character tab. : Many editors have the option of replacing tab with spaces, : i.e., when you type the tab key, the editor inserts spaces instead : of the tab character. : : terminal? : need
| T***B 发帖数: 137 | 11 there is a utility 'expand' in unix which can replace tabs in your
files to spaces. don't know if it is useful for you. |
|