Howdy, Stranger!

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

Categories

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, USAMember Posts: 1,035
    : 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]

  • AsmGuru62AsmGuru62 Member Posts: 6,519
    : : 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]
  • JamesTJamesT Member Posts: 16
    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
  • AsmGuru62AsmGuru62 Member Posts: 6,519
    [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]
  • Justin BibJustin Bib USAMember Posts: 0

    < http://forcoder.org /> free video tutorials and ebooks about | PL/SQL Objective-C Go R Scratch Perl Visual Basic C JavaScript C++ Delphi C# Python Ruby MATLAB Swift Java PHP Visual Basic .NET Assembly LabVIEW Julia Lua VBScript Scheme Dart Erlang Prolog FoxPro Bash Alice Transact-SQL Rust F# Scala D Lisp ABAP COBOL Logo Kotlin Apex Awk Ada Fortran Clojure Hack ML Crystal SAS | _________

Sign In or Register to comment.