import std.stdio;
import dmd.backend.aarray;
import zencoding.windows949;
struct Make_CP949Table(T)
{
private AArray!(Tinfo!T, T) aa;
this(T[] keys, T[] values)
{
foreach (i, T value; values)
{
T * set = aa.get(&keys[i]);
*set = value;
}
aa.rehash();
}
T* opBinaryRight(string op)(T index)
if (op == "in")
{
T* key = aa.get(&index);
if(*key > 0) return key;
return null;
}
T get(T key)
{
return *aa.get(&key);
}
size_t length()
{
return aa.nodes;
}
}
Make_CP949Table!ushort cp949_table;
shared static this() { cp949_table = Make_CP949Table!ushort(keys, values); }
void main()
{
const(ubyte[]) cp949 = [
...
0x00, 0x00, 0x00, 0x00];
const(ushort[]) utf16 = [
0xC774, 0xB354, 0x5F, 0xB0A8, 0x2E, 0x69, 0x6D, 0x66];
cp949.fromWindows949.writeln;
}