Thread: writing files (wchar_t)

  1. #1
    C++11 User Tux0r's Avatar
    Join Date
    Nov 2008
    Location
    Sweden
    Posts
    135

    Thumbs down writing files (wchar_t)

    Code:
    #include <stdio.h>
    #include <wchar.h>
    
    int main() {
    	FILE *f=fopen("test.txt","w");
    
    	fwprintf(f,L"едц");
    
    	fclose(f);
    
    	return 0;
    }
    For me this writes "???" to test.txt
    What's the proper way of writing "едц"?

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    i think to be able to include those characters in the source file, you have to use the proper encoding when you save the file, and give an option to whatever compiler your using (if it has any) to tell it your source file is unicode.
    if these two dont work, i would just try and write the unicode value of the character (ie hex or decimal representation of it).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with writing to files
    By beanroaster in forum C++ Programming
    Replies: 10
    Last Post: 12-23-2007, 12:21 AM
  2. Reading & Writing files (Error)
    By Blackroot in forum C++ Programming
    Replies: 9
    Last Post: 01-10-2006, 11:55 AM
  3. Writing files to a CD
    By SyntaxBubble in forum Windows Programming
    Replies: 1
    Last Post: 04-16-2003, 04:43 PM
  4. *.COM Files? Writing them?
    By johnc in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 07-11-2002, 01:52 AM
  5. Making files, opening them, and writing to them
    By Unregistered in forum Game Programming
    Replies: 6
    Last Post: 06-18-2002, 09:57 PM