#include <vector>
NLIB_PATHMAPPER_FORSAMPLE
char* ReadFile(size_t* size, const char* uri_path) {
char filename[1024];
InitPathMapperForSample();
e = g_pathmapper.ResolvePath(NULL, filename, uri_path);
if (e != 0) return NULL;
if (e != 0) return NULL;
if (e != 0) {
return NULL;
}
size_t filesize = static_cast<size_t>(filesize_);
if (!text) {
return NULL;
}
while (filesize > 0) {
size_t readsize;
if (e != 0) {
return NULL;
}
filesize -= readsize;
}
*size = static_cast<size_t>(filesize_);
}
std::vector<nlib_utf8_t>
GetUtf8(const char* first, const char* last) {
std::vector<nlib_utf8_t> vec;
while(!view.empty()) {
uint32_t cp = 0;
char c = *view.begin();
cp = cp * 16 + (c - '0');
} else {
cp = cp * 16 + (c - 'A' + 10);
}
view.remove_prefix(1);
}
NLIB_ASSERT(len > 0 && len <= 4);
vec.insert(vec.end(), &buf[0], &buf[0] + len);
}
return vec;
}
bool Nfkc(const std::vector<nlib_utf8_t>& vec, const std::vector<nlib_utf8_t>& ans) {
errno_t e =
nlib_nfkc(&result, &buf[0],
sizeof(buf), first, last, kNfkcDefault);
if (e != 0) return false;
if (ans.size() != result.
written)
return false;
if (memcmp(&buf[0], &*ans.begin(), ans.size()) != 0) return false;
return true;
}
bool NfkcNormalizeTest() {
size_t filesize;
if (!normalization_test) return false;
for (;;) {
if (line.
length() == 0)
break;
if (line[0] == '#' || line[0] == '@') continue;
size_t idx;
std::vector<nlib_utf8_t> c1 = GetUtf8(c1_.begin(), c1_.end());
std::vector<nlib_utf8_t> c2 = GetUtf8(c2_.begin(), c2_.end());
std::vector<nlib_utf8_t> c3 = GetUtf8(c3_.begin(), c3_.end());
std::vector<nlib_utf8_t> c4 = GetUtf8(c4_.begin(), c4_.end());
std::vector<nlib_utf8_t> c5 = GetUtf8(c5_.begin(), c5_.end());
nlib_utf8_t c1_str[64], c2_str[64], c3_str[64], c4_str[64], c5_str[64];
nlib_memcpy(&c1_str, sizeof(c1_str) - 1, &c1[0], c1.size());
nlib_memcpy(&c2_str, sizeof(c2_str) - 1, &c2[0], c2.size());
nlib_memcpy(&c3_str, sizeof(c3_str) - 1, &c3[0], c3.size());
nlib_memcpy(&c4_str, sizeof(c4_str) - 1, &c4[0], c4.size());
nlib_memcpy(&c5_str, sizeof(c5_str) - 1, &c5[0], c5.size());
nlib_printf(
"'%s' == toNFKC(%s) == toNFKC(%s) == toNFKC(%s) == toNFKC(%s) == toNFKC(%s)\n",
c4_str, c1_str, c2_str, c3_str, c4_str, c5_str);
if (!Nfkc(c1, c4)) return false;
if (!Nfkc(c2, c4)) return false;
if (!Nfkc(c3, c4)) return false;
if (!Nfkc(c4, c4)) return false;
if (!Nfkc(c5, c4)) return false;
}
return true;
}
bool SampleMain(int, char**) { return NfkcNormalizeTest(); }
NLIB_MAINFUNC