avatar
Question about tab# Java - 爪哇娇娃
j*r
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?
avatar
T*B
2
length of '\t' only depends on the editor/terminal you use to display it.
not sure, though.

【在 j******r 的大作中提到】
: 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?

avatar
o*v
3
u r right 【 在 TFIIB (小明) 的大作中提到: 】
avatar
j*r
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 的大作中提到】
: u r right 【 在 TFIIB (小明) 的大作中提到: 】
avatar
T*B
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 的大作中提到】
: 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,.).

avatar
j*r
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 的大作中提到】
: how do you get column number? you mean column number for '\t\t' is
: something like 8? that's weird.
:
: "x",
: it.

avatar
m*t
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 的大作中提到】
: 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'.

avatar
j*r
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 的大作中提到】
: \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-)

avatar
c*r
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 的大作中提到】
: 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.

avatar
e*g
10
death to tabs

【在 c****r 的大作中提到】
: 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

avatar
T*B
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.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。