Questions tagged [wofstream]

The C++ standard library type std::wofstream is a specialized std::wostream which uses a std::wfilebuf to write wide chars or wide strings to a file.

This is C++ std file output stream for data which has wide characters.

70 questions
1
vote
0 answers

Can std::wofstream << WCHAR and << CHAR at the same time?

How can we write WCHAR and CHAR to a wofstream at the same time?like this: wofstream << L"汉字" << "汉字" Here is something for testing. I can only "wofstream<
Li Da
  • 41
  • 4
1
vote
1 answer

CStdioFile Undeclared Identifier

I am unable to compile my code when using a CStdioFile type. I have included the afx.h header file but I am still receiving errors. What I am trying to do is write a cstring that contains an entire xml document to file. This cstring contains…
Eric Regnier
  • 43
  • 2
  • 4
1
vote
2 answers

Does this code work universaly, or is it just my system?

#include #include #include using namespace std; int main() { locale system(""); locale::global(system); wcin.imbue(system); wstring data; getline(wcin,data); …
Šimon Tóth
  • 35,456
  • 20
  • 106
  • 151
1
vote
1 answer

write Unicode strings into a txt file

I made my simple txt scanner who writes the text into a file that matches my selection. The problem is writing to file when instead of the pen writes, for example, 洀漀. On picture you can see for example: #include #include…
Marek
  • 147
  • 1
  • 13
1
vote
1 answer

wofstream only creates an empty file c++

I have a for loop (below) that should output several strings to several files using wofstream. Unfortunately, it creates the file but does not output the string to the file. The files are always empty. I've looked through a lot of similar questions…
ViperJuice
  • 13
  • 5
1
vote
2 answers

C++ std::wofstream unicode issue.

I wrote this code using VS 2012: std::wofstream logout("my_log.txt", std::ios_base::out | std::ios_base::trunc); std::locale utf8_locale(locale(), new codecvt_utf8); logout.imbue(utf8_locale); if (!logout.is_open()) { printf("Cannot open…
N. Zazulin
  • 35
  • 3
1
vote
1 answer

wofstream writes unnecessary byte

I am experimenting with with file output in utf-16 using wofstream, successfully so far. But I have got a problem to write a new line. As I found out with the Notepad and a hex editor, a new line on windows corresponds to 2 symbols: LineFedd and…
Andrey Pro
  • 501
  • 1
  • 10
  • 22
1
vote
2 answers

Why does my std::wofstream write ansi?

I've got wide string and I'm writing it to a wofstream that I opened in out|binary mode. When I look in the resultant file, it's missing every other byte. I was expecting that when I opened the file in visual studio with the binary editor that I'd…
Scott Langham
  • 58,735
  • 39
  • 131
  • 204
1
vote
2 answers

using wregex creates garbage output?

I created a simple program using regex to tokenize a file. For nonUnicode content it works fine. For a Unicode based content I made a wregex version but this version creates garbage output! I am trying to output Unicode characters or strings on a…
Hossein
  • 24,202
  • 35
  • 119
  • 224
1
vote
2 answers

Read/write unicode c++

Sadly this is the third time this week I have to post a question. I have to write text to a file with unicode encoding (or UTF8). This is what I do: creating wofstream mystream; and then I put a wstring in it like this mystream << L"hello…
HansElsen
  • 1,639
  • 5
  • 27
  • 47
1
vote
2 answers

how to get a single character from UTF-8 encoded URDU string written in a file?

i am working on Urdu Hindi translation/transliteration. my objective is to translate an Urdu sentence into Hindi and vice versa, i am using visual c++ 2010 software with c++ language. i have written an Urdu sentence in a text file saved as UTF-8…
saqib maqbool
  • 37
  • 2
  • 5
1
vote
3 answers

How can I print a Unicode CString (in Japanese) to a text file?

This seems like a tough one for me. I have this code that prints out a CString to a text file, but the value happens to be in Unicode (Japanese). As soon as this line is hit, nothing else below it gets printed. Any idea how can I print the Japanese…
SoftwareGuy
  • 41
  • 1
  • 9
1
vote
3 answers

How to write and read UTF16 file on Win using C++

There is a plenty of questions on SO regarding this, but most of them do not mention writing wstring back to file. So for example I found this for reading: // open as a byte stream std::wifstream fin("/testutf16.txt", std::ios::binary); // apply…
NoSenseEtAl
  • 28,205
  • 28
  • 128
  • 277
0
votes
1 answer

Wide Char To Multi-Byte

I'm trying to convert wide char into multi-byte. It's only on yje myfile part. The rest works fine.I can't use wofstream because I am using ofstream in several places, so I am left with this. void PrintBrowserInfo(IWebBrowser2 *pBrowser) { BSTR…
ME-dia
  • 289
  • 1
  • 5
  • 18
0
votes
1 answer

wofstream being truncated at wide data received from the registry

My wofstream is truncating when trying to write wide characters to the file. my_file << L"something"; wstring foo = //get a value from the registry .. // foo contains 您好 my_file << foo; my_file << "stuff that will never be seen";
Bluebaron
  • 2,289
  • 2
  • 27
  • 37