Thread: file I/O unicode

  1. #1
    Registered User Rare177's Avatar
    Join Date
    May 2004

    file I/O unicode

    hello , does any one know how to write wide chars to a file using i/o
    [C/win32 api]

  2. #2
    Join Date
    Jan 2002
    Using winapi, you would open a file for writing with CreateFile and use WriteFile to write to it. Just make sure that the nNumberOfBytesToWrite parameter of WriteFile is set to sizeof(TCHAR)*number_of_TCHARs_to_write (UNICODE defined!) or, sizeof(WCHAR) if you explicitly need to use that type. Don't forget to CloseHandle on the file when you're done.

    Here's the file io api functions; ReadFile is for reading. You may also be interested in IsTextUnicode if you're intending reading these wide char files you're writing.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User Rare177's Avatar
    Join Date
    May 2004


    thanks ill try it

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    You could also use Standard C File I/O routines if you want.

    Notice that all the character and string I/O routines have a wide, uincode version as well. For example, fwprintf() and fwscanf().


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie homework help
    By fossage in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 04:27 PM
  2. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 12:44 PM
  3. Subtle(?) File I/O Problem
    By cecomp64 in forum C Programming
    Replies: 9
    Last Post: 07-16-2008, 11:39 AM
  4. Unicode File I/O
    By mercury529 in forum C++ Programming
    Replies: 6
    Last Post: 11-26-2005, 12:51 PM
  5. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM