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
3
votes
1 answer

why std::wofstream do not print all wstring into file?

I have a std::wstring whose size is 139,580,199 characters. For debugging I printed it into file with this code: std::wofstream f(L"C:\\some file.txt"); f << buffer; f.close(); After that noticed that the end of string is missing. The created file…
ST3
  • 8,826
  • 3
  • 68
  • 92
3
votes
1 answer

Serialization example of boost/archive/binary_woarchive.hpp and/or boost/archive/binary_wiarchive.hpp?

I'm trying to find a good example of how to use these binary wide character versions of boost's serialization stuff. I pieced together some code to try and get it working, but unfortunately I get bombarded with linker errors when trying to compile…
Interminable
  • 1,338
  • 3
  • 21
  • 52
2
votes
2 answers

Can't write chinese character into textfile with wofstream

I'm using std::wofstream to write characters in a text file.My characters can have chars from very different languages(english to chinese). I want to print my vector into that file. If my vector contains only english characters I can print…
user7177818
2
votes
3 answers

Issue on writing wstring to a file for hebrew/arabic language

I want to read hebrew(unicode) using xerces parser. I am able to read the value in XMLCh. However, while writing it to another file I get gargabe value. I tried using ofstream, wofstream but didnot helped. Let me know your suggestions
Mamta
  • 21
  • 1
2
votes
1 answer

How to convert between shared_ptr to FILE* in C++?

I am trying to use a FILE pointer multiple times through out my application for this I though I create a function and pass the pointer through that. Basically I have this bit of code FILE* fp; _wfopen_s (&fp, L"ftest.txt", L"r"); …
Hossein
  • 24,202
  • 35
  • 119
  • 224
2
votes
0 answers

Display 'open with' context menu in own context menu

I've written a namespace extension (c++). What I want to do now is to copy the windows explorers 'open with' menu. I've implemented my context menu using IContextMenu, IContextMenu2 and IContextMenu3. I build a standard context menu for a dummy file…
MichaelB
  • 31
  • 2
2
votes
0 answers

Why don't I get any file output with wofstream?

My code is here: //wstring filename = temp.name + L".txt"; wstring filename = L"hero2.txt"; //wofstream File(filename.c_str()); wofstream outputFile(L"temp.txt", ios::ate | ios::binary); if (outputFile.fail()) windowmsg(1, LPCWSTR(L"Could not Save…
user1397417
  • 708
  • 4
  • 11
  • 34
1
vote
2 answers

C++ swallowing errors

I'm writing an application that communicates through the Windows RPC mechanism with a hosted interface in another process. The marshaling is handled through the standard built-in NDR. The interface exposes several functions, among them one that…
Karim Agha
  • 3,606
  • 4
  • 32
  • 48
1
vote
3 answers

Typographic apostrophe + wide string literal broke my wofstream (C++)

I’ve just encountered some strange behaviour when dealing with the ominous typographic apostrophe ( ’ ) – not the typewriter apostrophe ( ' ). Used with wide string literal, the apostrophe breaks wofstream. This code works ofstream…
singinanarchist
1
vote
1 answer

File truncates after hitting a wide character

While trying to write some wide characters to a file, all output to the file stops after those characters. I don't know what's going on. wofstream file("c:\\test.txt"); file << L"seen" << L"您好" << "unseen";
Bluebaron
  • 2,289
  • 2
  • 27
  • 37
1
vote
2 answers

Reading and writing files in Cyrillic in c++

I have to first read a file in Cyrillic, then randomly pick random number of lines and write modified text to a different file. No problem with Latin letter, but I run into a problem with Cyrillic text, because I get some rubbish. So this is how I…
Sergei G
  • 1,550
  • 3
  • 24
  • 44
1
vote
0 answers

wofstream not writing Japanese Characters in file

I'm trying to write Japanese to a file using wofstream and wstring. Unfortunately, wofstream doesn't write Japanese characters to the file when compiled with g++ or clang++ (in WSL and Windows 10) with no additional flags. #include int…
Someone
  • 126
  • 8
1
vote
1 answer

How to add arabic characters in a middle of a file using C++?

I am building an application that will need to add arabic characters in the middle of english file, I build the function as follow: int main(void) { std::ifstream mySource("Test2.txt", std::ios::out); std::filebuf* pbuf = mySource.rdbuf(); …
1
vote
1 answer

What's the canonical way to use the fmtlib with wofstream

We're switching to the fmt library and aim to rewrite many wide character output stream based formattings. I found fmt::output_file which returns a class ostream : private detail::buffer instance but it looks like there's no support for…
jesses
  • 559
  • 3
  • 15
1
vote
2 answers

Print to file via wofstream

Below code does not work and give the compilation error of: Severity Code Description Project File Line Suppression State Error invalid operands to binary expression ('std::wofstream' (aka 'basic_ofstream >')) And the code is: template…
KC_
  • 89
  • 11