なんなら日本語のファイルを読んで、コードを出力してみればいいわけですね。
ロケールを設定する必要があります。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
using namespace std; | |
void binary(int16_t x) | |
{ | |
for(int i=15;0<=i;i--) | |
{ | |
cout << ((x>>i)&1); | |
} | |
cout << endl; | |
} | |
int main() | |
{ | |
setlocale(LC_CTYPE,""); | |
wstring str; | |
char fn[]="uni.txt"; | |
wifstream fin; | |
fin.open(fn,ios::binary); | |
if(fin) | |
{ | |
fin >> str; | |
binary(str[0]); | |
wcout << str << endl; | |
} | |
return 0; | |
} |