回答編集履歴
1
#include を追加
answer
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Shift-JIS
|
2
2
|
```cpp
|
3
|
+
#include <iostream>
|
4
|
+
#include <fstream>
|
5
|
+
#include <string>
|
6
|
+
|
3
7
|
ifstream ifs("shift-jis.txt");
|
4
8
|
string str((istreambuf_iterator<char>(ifs)), istreambuf_iterator<char>());
|
5
9
|
|
@@ -8,6 +12,11 @@
|
|
8
12
|
|
9
13
|
# UTF-8(BOMなし)
|
10
14
|
```cpp
|
15
|
+
#include <iostream>
|
16
|
+
#include <fstream>
|
17
|
+
#include <string>
|
18
|
+
#include <codecvt>
|
19
|
+
|
11
20
|
setlocale(LC_ALL, "");
|
12
21
|
|
13
22
|
wifstream ifs("UTF-8N.txt");
|
@@ -19,6 +28,11 @@
|
|
19
28
|
|
20
29
|
# UTF-8(BOMあり)
|
21
30
|
```cpp
|
31
|
+
#include <iostream>
|
32
|
+
#include <fstream>
|
33
|
+
#include <string>
|
34
|
+
#include <codecvt>
|
35
|
+
|
22
36
|
setlocale(LC_ALL, "");
|
23
37
|
|
24
38
|
wifstream ifs("UTF-8(BOM).txt");
|
@@ -30,6 +44,11 @@
|
|
30
44
|
|
31
45
|
# UTF-16 リトルエンディアン (BOMなし)
|
32
46
|
```cpp
|
47
|
+
#include <iostream>
|
48
|
+
#include <fstream>
|
49
|
+
#include <string>
|
50
|
+
#include <codecvt>
|
51
|
+
|
33
52
|
setlocale(LC_ALL, "");
|
34
53
|
|
35
54
|
wifstream ifs("UTF-16LEN.txt");
|
@@ -41,6 +60,11 @@
|
|
41
60
|
|
42
61
|
# UTF-16 リトルエンディアン (BOMあり)
|
43
62
|
```cpp
|
63
|
+
#include <iostream>
|
64
|
+
#include <fstream>
|
65
|
+
#include <string>
|
66
|
+
#include <codecvt>
|
67
|
+
|
44
68
|
setlocale(LC_ALL, "");
|
45
69
|
|
46
70
|
wifstream ifs("UTF-16LE(BOM).txt");
|
@@ -52,6 +76,11 @@
|
|
52
76
|
|
53
77
|
# UTF-16 ビッグエンディアン (BOMなし)
|
54
78
|
```cpp
|
79
|
+
#include <iostream>
|
80
|
+
#include <fstream>
|
81
|
+
#include <string>
|
82
|
+
#include <codecvt>
|
83
|
+
|
55
84
|
setlocale(LC_ALL, "");
|
56
85
|
|
57
86
|
wifstream ifs("UTF-16BEN.txt");
|
@@ -63,6 +92,11 @@
|
|
63
92
|
|
64
93
|
# UTF-16 ビッグエンディアン (BOMあり)
|
65
94
|
```cpp
|
95
|
+
#include <iostream>
|
96
|
+
#include <fstream>
|
97
|
+
#include <string>
|
98
|
+
#include <codecvt>
|
99
|
+
|
66
100
|
setlocale(LC_ALL, "");
|
67
101
|
|
68
102
|
wifstream ifs("UTF-16BE(BOM).txt");
|