Sign in to follow this  
peter_b

Tabs in strings?

Recommended Posts

peter_b    200
This produces no tab: const char* c = "before_tab \t after_tab"; Havent used tabs in a while, i seem to remember \t was correct? :O

Share this post


Link to post
Share on other sites
Michalson    1657
What exactly are you using to output the string? I came into this thread expecting a more output related explaination, since tabs are stored just fine, even in C style strings, it's all the different methods of outputing a character string that can mangle tabs, since a "tab" is not a well defined entity, especially in the absence of a page structure. A tab might be defined as 3 spaces, or it might be defined as a fixed set of character positions (like every 1", in which case a tab in the wrong position might seem to disappear), or any other factor made up by your libraries character string outputing method.

Share this post


Link to post
Share on other sites
peter_b    200
Its a draw_string() function for the api im using. So if i just get a funny character where the tab should be, drawing it is not supported? The thing is if i look at the context of the string in the debugger msvc dosn't show a tab either.

But it is \t then? Even for wide strings?

Share this post


Link to post
Share on other sites
Anon Mike    1098
\t is tab yeah. But there's no law that says some random api needs to actually implement the tabbing logic. Probably it's just not supported.

Share this post


Link to post
Share on other sites
peter_b    200
Could there be no other explanation?
The api im using is provided by Microsoft and supports a hell-alot of languages. Strange it should not support tabs.. :O

Share this post


Link to post
Share on other sites
Palidine    1315
Quote:
Original post by peter_b
The api im using is provided by Microsoft and supports a hell-alot of languages. Strange it should not support tabs.. :O


It's more a problem with the font than the api. use a different font that has a 'tab' character as part of it's character set. Alternately pre-process your strings and replace all instances of '\t' with 4 ' '.

-me

Share this post


Link to post
Share on other sites
Anon Mike    1098
It's unlikely to have anything to do with the font. A font may have some glyph defined for the tab character but fonts don't know anything about "insert so-many spaces" or "move the cursor over to there".

Most Microsoft GUI API's don't expand tabs, at least not by default. It doesn't really make a lot of sense to do so since most GUI apps want precise control over where things go and thus wouldn't use tabs anyway. Since you haven't mentioned your specific api it's hard to give concrete advise. In Win32 you can either call TabbedTextOut or DrawText with the DT_EXPANDTABS flag.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this