1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| //OS cible
#include <windows.h>
//SL
#include <iostream>
#include <sstream>
#include <string>
#include <cwchar>
#include <cstdio>
#include <locale.h>
#include <unistd.h>
int main(){
//char wc[]={0,0x42, 0,0x43, 0,0xD, 0,0xA, 0,0xD, 0,0xA, 0,0x44, 0,0};
char wc[]={0x42,0, 0x43,0, 0xD,0, 0xA,0, 0xD,0, 0xA,0, 0x44,0, 0,0};
wchar_t ws []= L"WWWWWWWWWW";
//int newstdout= dup(0);
//FILE* f=fdopen(newstdout, "wb+");
FILE* f=fopen("tmp.txt", "wb+");
std::wcout<< f<< std::endl;
std::wcout<<
fwprintf(f, reinterpret_cast<wchar_t*>(wc))<< std::endl;
fwide(f, 1);
rewind (f);
//std::wcout<<
// fwscanf(f, L"%ls", ws)<< std::endl;
size_t wchars_reading;
std::wcout<<
(wchars_reading= fread(ws, sizeof(wchar_t), sizeof(wc)/sizeof(wchar_t), f))
<< std::endl;
ws[wchars_reading]=L'\0';
wprintf(L"%ls\n", ws);
//std::wostringstream woss;
// woss<<;
std::wcout<< L"A"<< ws<<L"E" <<std::endl;
fclose(f);
return 0;
}
// |
Partager