How to handle Tab key in a text file.

Hi:everybody

When my program read a text file, I will copy each character one by one, when meet Tab key(equal 9), it is copied, by when shows on my
window,just like this: |, so the text format chage quite a
lot.

I am just wandering how can I deal with this.

Thanks a lot.

James

Comments

  • SephirothSephiroth Fayetteville, NC, USA
    : Hi:everybody
    :
    : When my program read a text file, I will copy each character one by one, when meet Tab key(equal 9), it is copied, by when shows on my
    : window,just like this: |, so the text format chage quite a
    : lot.
    :
    : I am just wandering how can I deal with this.
    :
    : Thanks a lot.
    :
    : James
    :
    :
    Uh, if you're reading a text file in text format, a TAB reads in as ' '. Show me the line of code (or function body) that reads in your characters and I'll see if I can locate the error. Just post it here if you want.

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

  • : : Hi:everybody
    : :
    : : When my program read a text file, I will copy each character one by one, when meet Tab key(equal 9), it is copied, by when shows on my
    : : window,just like this: |, so the text format chage quite a
    : : lot.
    : :
    : : I am just wandering how can I deal with this.
    : :
    : : Thanks a lot.
    : :
    : : James
    : :
    : :
    : Uh, if you're reading a text file in text format, a TAB reads in as ' '. Show me the line of code (or function body) that reads in your characters and I'll see if I can locate the error. Just post it here if you want.
    :
    : -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]
    :
    :
    [blue]What are you using to display the text?[/blue]
  • Hi: Guys:
    Thank you all for your emails.

    Lets assume in my Notepad the text file only has this:
    hello! world.
    but before each word has two tab key.

    --------------------code start--------------------------------
    ReadFile(hFile, cMyBuffer, MAXSIZE, &dwNumRead, NULL);
    for(int i = 0; i < dwNumRead; i++)
    cString[i] = cMyBuffer[i]; //cMyBuffer[i] equals 9 if it is a Tab key.

    TextOut (hdc, 0, 0, cString, lstrlen(cString));//will show: ||hello!||world

    -------------------code end-------------------------------------

    above code is a little bit modified, but I just let you know where is the 9 comes from, and why the | shows.

    Any idea or suggestion will be appreciated!

    James
  • [blue]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winprog/winprog/functions_by_category.asp

    From there go: [b]Font and Text[/b]
    And then function: [b]DrawText()[/b]
    Use flag: [b]DT_EXPANDTABS[/b][/blue]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories