CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10
  1. #1
    Join Date
    Nov 2013
    Posts
    24

    Using FILE class to write into txt file in DOS Codepage

    I'm using

    CString text;
    CString file_name;
    text = "My text.";
    file_name = "MyFile.txt";
    FILE *fp;
    fp = fopen(file_name, "w+");
    fprintf(fp, text + "\n");
    fclose(fp);


    There will be MyFile.txt in Windows codepage.

    How to write to txt file with DOS codepage?

  2. #2
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Using FILE class to write into txt file in DOS Codepage

    >> text = "My text."
    Those characters have the same code points in all encodings. What characters are you trying to write that are different in the OEM codepage vs ACP codepage?

    gg

  3. #3
    Join Date
    Nov 2013
    Posts
    24

    Re: Using FILE class to write into txt file in DOS Codepage

    Instead of "My text." will be another text.
    I can not give you that text.
    I must to safe in two txt files:
    1. With MS-DOS Encoding.
    2. With MS-Windows Encoding.

  4. #4
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Using FILE class to write into txt file in DOS Codepage

    Which DOS encoding? Which "Windows" encoding?

    In my locale, the DOS encoding is 437 and my ACP is 1252.

    gg

  5. #5
    Join Date
    Nov 2013
    Posts
    24

    Re: Using FILE class to write into txt file in DOS Codepage

    CharToOem

  6. #6
    Join Date
    Nov 2013
    Posts
    24

    Re: Using FILE class to write into txt file in DOS Codepage

    Thank you.
    Which OS do you use?

  7. #7
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Using FILE class to write into txt file in DOS Codepage

    CharToOem coverts an ACP encoding into an OEM encoding. The actual codepage depends on the locale. For me, OEM=437 and ACP=1252.

    I'm running Win7 with a US locale. Other locales will have different ACP/OEM codepages.

    gg

  8. #8
    Join Date
    Nov 2013
    Posts
    24

    Re: Using FILE class to write into txt file in DOS Codepage

    Thank you.
    By the way, could you tell me, which instrument must be used to create some bare metal utilities and OS ?

    Quote Originally Posted by Codeplug View Post
    CharToOem coverts an ACP encoding into an OEM encoding. The actual codepage depends on the locale. For me, OEM=437 and ACP=1252.

    I'm running Win7 with a US locale. Other locales will have different ACP/OEM codepages.

    gg

  9. #9
    Join Date
    Nov 2003
    Posts
    1,902

    Re: Using FILE class to write into txt file in DOS Codepage

    >> ... which instrument must be used to create some bare metal utilities and OS ?
    It may be better if you state exactly what you're trying to achieve. I don't know what "bare metal" means.

    gg

  10. #10
    Join Date
    Nov 2013
    Posts
    24

    Re: Using FILE class to write into txt file in DOS Codepage

    It means without starting operating system (OS) or without installed OS.
    Quote Originally Posted by Codeplug View Post
    >> ... which instrument must be used to create some bare metal utilities and OS ?
    It may be better if you state exactly what you're trying to achieve. I don't know what "bare metal" means.

    gg

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured