-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaxpathlist2ex_test.cpp
91 lines (78 loc) · 2.32 KB
/
axpathlist2ex_test.cpp
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include "axpathlist2ex.cpp"
#include <io.h>
#include <fcntl.h>
#include <assert.h>
#include <fstream>
#include <sstream>
#include <codecvt>
#include <Shlwapi.h>
#include <crtdbg.h>
#define _CRTDBG_MAP_ALLOC
#define new ::new(_NORMAL_BLOCK, __FILE__, __LINE__)
const BYTE rawData[3579] = {
0x44, 0x3A, 0x5C, 0x44, 0x6F, 0x77, 0x6E, 0x6C, 0x6F, 0x61, 0x64, 0x73,
0x5C, 0x4E, 0x47, 0x2E, 0x72, 0x61, 0x62, 0x62, 0x69, 0x74, 0x8E, 0x64,
0x8E, 0x96, 0x95, 0xE5, 0x8F, 0x57, 0x92, 0x86, 0x20, 0x2D,
};
const BYTE rawData2[] = "# coding: shift-jis\r\aaaa";
int main()
{
using namespace std;
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
{
HANDLE hFile = ::CreateFile(L"shiftjis.txt", 0, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
::IsSupported("", (DWORD)hFile);
auto p = ::PathFindFileName(L"x");
assert(p);
}
{
auto buf = new char[100 * 1024 * 1024]();
buf[0] = 'A';
buf[1] = '\n';
string s(buf, buf + 100 * 1024 * 1024);
istringstream is(s,std::istringstream::binary);
//is.rdbuf()->pubsetbuf(buf, 100 * 1024 * 1024);
delete buf;
is.imbue(std::locale(std::locale("", LC_CTYPE)));
string line;
std::getline(is, line);
auto c = is.get();
Sleep(0);
}
static_assert(sizeof(wchar_t) == 2, "error.");//Linuxではつかうcvt違うから直してくれ
std::wstring buf;
{
std::wifstream file;
file.open("utf8bom.txt");
file.imbue(std::locale(std::locale(""), new std::codecvt_utf8_utf16<wchar_t, 0x10ffff, std::consume_header>()));
if (!file) return -1;
std::getline(file, buf);
}
buf.clear();
{
std::wifstream file;
file.open("utf8.txt");
file.imbue(std::locale(std::locale(""), new std::codecvt_utf8_utf16<wchar_t, 0x10ffff, std::consume_header>()));
if (!file) return -1;
std::getline(file, buf);
}
buf.clear();
{
std::wifstream file;
file.open("shiftjis.txt");
file.imbue(std::locale(std::locale("", LC_CTYPE)));
if (!file) return -1;
std::getline(file, buf);
}
buf.clear();
buf.clear();
{
std::wifstream file;
file.open("utf16.txt");
file.imbue(std::locale(std::locale(""), new std::codecvt_utf16<wchar_t, 0x10ffff, static_cast<std::codecvt_mode>(std::little_endian | std::consume_header)>));
if (!file) return -1;
std::getline(file, buf);
}
assert(detectEncoding(rawData2, _countof(rawData2)));
assert(detectEncoding(rawData, _countof(rawData)));
}