title: How to write files with (readable) UTF8 characters?
body: <p>I read a file that has utf8 characters like this:</p>
  
  <pre><code>FILE *FileIN,*FileOUT;
  FileIN=fopen("filename","r");
  char string[600];
  WideChar C[600],S[100];
  fgets(string,600,FileIN);
  wcscpy(C,UTF8Decode(string).c_bstr()); // widechar copy
  </code></pre>
  
  <p>And it reads it perfectly (this is shown in the Editbox when running the program):</p>
  
  <pre><code>Edit1-&gt;Text=C;
  
  Result ===&gt; "3021";"亜";"7";"ア アシア つ.ぐ T1 や つぎ つぐ"
  </code></pre>
  
  <p>The thing is that when I want to write this on a file:</p>
  
  <pre><code>FileOUT=fopen("txt.txt","w");    
  fwrite(Edit8-&gt;Text.c_str(),strlen(Edit8-&gt;Text.c_str()),1,FileOUT);
  
  Result ===&gt; "3021";"?";"7";"? ??? ?.? T1 ? ?? ??"
  </code></pre>
  
  <p>The question is, how do I write the result (the one i can see in the program running) in a file?</p>
  
  <p>I use C language on CodeGear C++Builder </p>
  
  <p><strong>Resolved</strong>
  thanks to Christoph and nobugz for the help</p>
  
  <p>I changed this line</p>
  
  <pre><code>fwrite(Edit8-&gt;Text.c_str(),strlen(Edit8-&gt;Text.c_str()),1,FileOUT);
  </code></pre>
  
  <p>to this one and it worked. Thanks</p>
  
  <pre><code>fwrite(UTF8Encode(Edit8-&gt;Text).c_str(),UTF8Encode(Edit8-&gt;Text).Length(),1,FileOUT);
  </code></pre>