Jump to content
  • Advertisement
Sign in to follow this  
peter_b

Tabs in strings?

This topic is 4070 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
It just means that tab isn't a character that has a bitmap representation in the font you are using.

-me

Share this post


Link to post
Share on other sites
\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
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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!