473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to write a unicode string to file

#include <fstream>
#include "stdio.h"

int main()
{
// std::wofstream strm2("test.txt");
// strm2 << L"ÎÒ°®±±¾©Ìì°²ÃÅ";

FILE *hFile = fopen("test.txt", "wb+");
wchar_t *buffer = L"ÎÒ°®±±¾©Ìì°²ÃÅ";
fwrite (buffer , sizeof(buffer[0]) , 7 , hFile );
fclose (hFile);

return 0;
}

The program works. But how could i use wofstream in STL to write a
unicode string to file? The code above which is commented does not
work.

Mar 30 '07 #1
0 2570

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: burdeen | last post by:
I can't find any way of writing a unicode, or UTF-8 format text file. Right now i have a Unicode string that i write to the text file and the unicode characters are replaced with ANSI question...
3
by: Mark Miller | last post by:
I have a char array and when I write it to a file using BinaryWriter the position of the pointer is the size of the array + 1. For example: writing char leaves the pointer at position 26 after...
9
by: Charles F McDevitt | last post by:
I'm trying to upgrade some old code that used old iostreams. At one place in the code, I have a path/filename in a wchar_t string (unicode utf-16). I need to open an ifstream to that file. ...
3
by: john | last post by:
I need to produce a RTF-document which is filled with data from a database. I've created a RTF-document in WordPad (a template, so to speak) which contains 'placeholders', for example '<dd01>',...
10
by: Tibby | last post by:
I need to read/write not only text files, but binary as well. It seems like on binary files, it doesn't right the last 10% of the file. -- Thanks --- Outgoing mail is certified Virus...
0
by: Ahmed A. | last post by:
This will be very helpfull for many! Using RichTextBox Read/Write Unicode File http://www.microsoft.com/indonesia/msdn/wnf_RichTextBox.as p Private Function ReadFile(ByVal myfile As String)...
10
by: Nikolay Petrov | last post by:
How can I convert DOS cyrillic text to Unicode
3
by: Billy Smith | last post by:
I'm trying to write a little utility that will write some binary data to a file via a javascript and Windows Script Host under Windows XP. The only way to do this that I can find is to convert...
1
by: raj.sinha | last post by:
I have to "PUT" data to a Unicode file... a file that has the "FF FE" mark at the beginning of the file. How do i do that. What HTTP header do i need to send so that the data is stored in the...
2
by: Frank Potter | last post by:
I want to change an srt file to unicode format so mpalyer can display Chinese subtitles properly. I did it like this: txt=open('dmd-guardian-cd1.srt').read() txt=unicode(txt,'gb18030')...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.