private import std.c.windows.windows;
private import std.windows.syserror;
private import std.utf;
private import std.string;
string charctorEncodingConvert(const(char[]) str, uint formCodePage, uint toCodePage)
{
version(Windows)
{
int result;
wchar[] wstr;
char[] rstr;
result = MultiByteToWideChar(formCodePage, 0, str.ptr, str.length, null, 0);
wstr.length = result;
MultiByteToWideChar(formCodePage, 0, str.ptr, str.length, wstr.ptr, wstr.length);
result = WideCharToMultiByte(toCodePage, 0, wstr.ptr, wstr.length, null, 0, null, null);
rstr.length = result;
WideCharToMultiByte(toCodePage, 0, wstr.ptr, wstr.length, rstr.ptr, rstr.length, null, null);
return cast(immutable)rstr;
}
else version(Posix)
{
}
else
{
static assert(0);
}
}
cHJpdmF0ZSBpbXBvcnQgc3RkLmMud2luZG93cy53aW5kb3dzOwpwcml2YXRlIGltcG9ydCBzdGQud2luZG93cy5zeXNlcnJvcjsKcHJpdmF0ZSBpbXBvcnQgc3RkLnV0ZjsKcHJpdmF0ZSBpbXBvcnQgc3RkLnN0cmluZzsKCnN0cmluZyBjaGFyY3RvckVuY29kaW5nQ29udmVydChjb25zdChjaGFyW10pIHN0ciwgdWludCBmb3JtQ29kZVBhZ2UsIHVpbnQgdG9Db2RlUGFnZSkKewoJdmVyc2lvbihXaW5kb3dzKQoJewoJCWludCByZXN1bHQ7CgkJd2NoYXJbXSB3c3RyOwoJCWNoYXJbXSByc3RyOwoKCQlyZXN1bHQgPSAgTXVsdGlCeXRlVG9XaWRlQ2hhcihmb3JtQ29kZVBhZ2UsIDAsIHN0ci5wdHIsIHN0ci5sZW5ndGgsIG51bGwsIDApOwoJCXdzdHIubGVuZ3RoID0gcmVzdWx0OwoJCU11bHRpQnl0ZVRvV2lkZUNoYXIoZm9ybUNvZGVQYWdlLCAwLCBzdHIucHRyLCBzdHIubGVuZ3RoLCB3c3RyLnB0ciwgd3N0ci5sZW5ndGgpOwoJCQoJCXJlc3VsdCA9IFdpZGVDaGFyVG9NdWx0aUJ5dGUodG9Db2RlUGFnZSwgMCwgd3N0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