wofstream

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

孤街醉人 提交于 2019-12-01 21:54:55
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 it. Here's my code, in case I'm doing anything obviously wrong: #include <cstdlib> #include <iostream> #include <fstream> #include <string> #include <vector> #include <boost/archive/binary_woarchive.hpp> #include <boost/archive/binary_wiarchive.hpp> class testClass { public: testClass() { } testClass(const int intInput, const std::wstring stringInput

Outputting 'wchar_t*' to an 'ofstream'

强颜欢笑 提交于 2019-11-30 17:29:37
I want to output a text to a file via two pointers that I have declared: wchar_t *Col1="dsffsd", *Col2="sdfsf"; Here is what I have tried: std::ofstream fout; fout.open(NativeDatabasePathHist); fout<<"testing"; fout<<" "<<Col1<<" "<<Col2; fout.close(); And here is what I am getting: testing 113 113 Why is it that when I print Col1 and Col2 , I am getting numbers instead of strings? Dmitriy First, use std::wofstream instead of std::ofstream . Also, use the L prefix on your text string to indicate that your text is wide character text: wchar_t *Col1=L"dsffsd" Since you have written it using wide

How to read a UCS-2 file?

旧巷老猫 提交于 2019-11-29 22:27:42
问题 I'm writing a program to get the infomation in *.rc file encoding in UCS-2 Little Endian. int _tmain(int argc, _TCHAR* argv[]) { wstring csvLine(wstring sLine); wifstream fin("en.rc"); wofstream fout("table.csv"); wofstream fout_rm("temp.txt"); wstring sLine; fout << "en\n"; while(getline(fin,sLine)) { if (sLine.find(L"IDS") == -1) fout_rm << sLine << endl; else fout << csvLine(sLine); } fout << flush; system("pause"); return 0; } The first line in "en.rc" is #include <windows.h> but sLine

Unable to write a std::wstring into wofstream

浪子不回头ぞ 提交于 2019-11-29 11:39:40
I'm using Qt/C++ on a Linux system. I need to convert a QLineEdit 's text to std::wstring and write it into a std::wofstream . It works correctly for ascii strings, but when I enter any other character (Arabic or Uzbek) there is nothing written in the file. (size of file is 0 bytes). this is my code: wofstream customersFile; customersFile.open("./customers.txt"); std::wstring ws = lne_address_customer->text().toStdWString(); customersFile << ws << ws.length() << std::endl; Output for John Smith entered in the line edit is John Smith10 . but for unicode strings, nothing. First I thought that is

Unable to write a std::wstring into wofstream

谁都会走 提交于 2019-11-28 04:51:59
问题 I'm using Qt/C++ on a Linux system. I need to convert a QLineEdit 's text to std::wstring and write it into a std::wofstream . It works correctly for ascii strings, but when I enter any other character (Arabic or Uzbek) there is nothing written in the file. (size of file is 0 bytes). this is my code: wofstream customersFile; customersFile.open("./customers.txt"); std::wstring ws = lne_address_customer->text().toStdWString(); customersFile << ws << ws.length() << std::endl; Output for John

Wrote to a file using std::wofstream. The file remained empty

江枫思渺然 提交于 2019-11-27 14:24:25
I wrote the following program using VS2008: #include <fstream> int main() { std::wofstream fout("myfile"); fout << L"Հայաստան Россия Österreich Ελλάδα भारत" << std::endl; } When I tried to compile it the IDE asked me whether I wanted to save my source file in unicode, I said "yes, please". Then I run the program, and myfile appeared in my project's folder. I opened it with notepad, the file was empty. I recalled that notepad supported only ASCII data. I opened it with WordPad, it was still empty. Finally the little genius inside me urged me to look at the file size and not surprisingly it was

Windows Unicode C++ Stream Output Failure

我与影子孤独终老i 提交于 2019-11-27 08:42:51
I am currently writing an application which requires me to call GetWindowText on arbitrary windows and store that data to a file for later processing. Long story short, I noticed that my tool was failing on Battlefield 3, and I narrowed the problem down to the following character in its window title: http://www.fileformat.info/info/unicode/char/2122/index.htm So I created a little test app which just does the following: std::wcout << L"\u2122"; Low and behold that breaks output to the console window for the remainder of the program. Why is the MSVC STL choking on this character (and I assume

Why does wide file-stream in C++ narrow written data by default?

旧街凉风 提交于 2019-11-27 04:24:47
Honestly, I just don't get the following design decision in C++ Standard library. When writing wide characters to a file, the wofstream converts wchar_t into char characters: #include <fstream> #include <string> int main() { using namespace std; wstring someString = L"Hello StackOverflow!"; wofstream file(L"Test.txt"); file << someString; // the output file will consist of ASCII characters! } I am aware that this has to do with the standard codecvt . There is codecvt for utf8 in Boost . Also, there is a codecvt for utf16 by Martin York here on SO . The question is why the standard codecvt

Windows Unicode C++ Stream Output Failure

邮差的信 提交于 2019-11-26 14:17:00
问题 I am currently writing an application which requires me to call GetWindowText on arbitrary windows and store that data to a file for later processing. Long story short, I noticed that my tool was failing on Battlefield 3, and I narrowed the problem down to the following character in its window title: http://www.fileformat.info/info/unicode/char/2122/index.htm So I created a little test app which just does the following: std::wcout << L"\u2122"; Low and behold that breaks output to the console

Why does wide file-stream in C++ narrow written data by default?

▼魔方 西西 提交于 2019-11-26 11:09:56
问题 Honestly, I just don\'t get the following design decision in C++ Standard library. When writing wide characters to a file, the wofstream converts wchar_t into char characters: #include <fstream> #include <string> int main() { using namespace std; wstring someString = L\"Hello StackOverflow!\"; wofstream file(L\"Test.txt\"); file << someString; // the output file will consist of ASCII characters! } I am aware that this has to do with the standard codecvt . There is codecvt for utf8 in Boost.