c - Query on handling TAB character? -
in ascii characterset
world, below 3 whitespace characters have number.
space(32) linefeed(10) carriagereturn(13)
so, easy write programme read or write such whitespace characters in standard way using programming language(like c) in portable way, using next notations,
linefeed - '\n' carriage homecoming - '\r' space - ' '
i learnt tab
collection of 4 or 8 space
characters.
my question:
how understand meaning of '\t' character in programming language(like c)? when there no standard definition of tab in characterset
world?
in ascii, horizontal tab code 9. ascii horizontal tab code 9 regardless of character set code written in.
in c, '\t'
horizontal tab in character set of source code, regardless of character set of io. integer value of '\t'
may/may not 9.
the character set of code , character set of io (e.g. files) commonly same. in 2014, there both ascii (at to the lowest degree ascii codes 0 - 127).
in c, printing '\t'
precise;
moves active position next horizontal tabulation position on current line. if active position @ or past lastly defined horizontal tabulation position, behavior of display device unspecified. c11 §5.2.2 2
with ascii, horizontal tab intended not represent printable information, rather command devices. ascii original definition led ambiguity precise action of command device: move next tabulation stop.
given these similar, different meanings, , acknowledging other languages have various meanings, precise meaning highly dependent on situation. hence maintain portability, other situation dependent info needed (e. g. definition or list of tab stops) precisely generate , interpret horizontal tab.
recommend: unless info format requires ( csv, makefile), not generate tabs, spaces. upon reading '\t'
, interpret it, able, same 1 or more consecutive spaces.
c language-agnostic
No comments:
Post a Comment