#if 0

#include "TCore.h"

static const byte CsLatin2_1250[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,

	0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
	0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,

	0xC8,0xFC,0xE9,0x61,0xE4,0xF9,0x63,0x63,0x41,0x65,0x4F,0x6F,0x69,0x5A,0xC4,0x43,
	0xC9,0xC5,0xC2,0xF4,0xF6,0xBC,0xBE,0x53,0x73,0xD6,0xDC,0x8D,0x9D,0x4C,0x78,0xE8,
	0xE1,0xED,0xF3,0xFA,0x41,0x61,0x8E,0x9E,0x45,0x65,0x20,0x7A,0xC8,0x73,0xAB,0xBB,
	0x5F,0x5F,0x5F,0xA6,0xA6,0xC1,0x41,0xCC,0x53,0xA6,0xA6,0x2B,0x2B,0x5A,0x7A,0x2B,

	0x2B,0x2D,0x2D,0x2B,0x2D,0x2B,0x41,0x61,0x2B,0x2B,0x2D,0x2D,0xA6,0x2D,0x2B,0x2A,
	0x64,0x44,0xCF,0x45,0xEF,0xD2,0xE5,0x49,0xEC,0x2B,0x2B,0x5F,0x5F,0xDE,0xD9,0x5F,
	0xD3,0xDF,0xD4,0x4E,0x6E,0xF2,0x8A,0x9A,0xC0,0xDA,0xE0,0x55,0xFD,0xDD,0x74,0x60,
	0x2D,0x22,0x2E,0x5E,0x7E,0xBA,0xF7,0xB8,0xB0,0xA8,0xB7,0x75,0xD8,0xF8,0x5F,0x20,

};

const String& NlsLatin2To1250()
{
	static String cp(CsLatin2_1250 + 128, 128);
	return cp;
}

static const byte CsMJK_1250[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,

	0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
	0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,

	0xC8,0xFC,0xE9,0xEF,0xE4,0xCF,0x8D,0xE8,0xEC,0xCC,0xC5,0xCD,0xBE,0xE5,0xC4,0xC1,
	0xC9,0x9E,0x8E,0xF4,0xF6,0xD3,0xF9,0xDA,0xFD,0xD6,0xDC,0x8A,0xBC,0xDD,0xD8,0x9D,
	0xE1,0xED,0xF3,0xFA,0xF2,0xD2,0xD9,0xD4,0x9A,0xF8,0xE0,0xC0,0xAC,0xA7,0xBB,0xAB,
	0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,

	0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,
	0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
	0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xB5,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,
	0xF0,0xB1,0xF2,0xF3,0xF4,0xF5,0xF7,0xF7,0xB0,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
};

const String& NlsMJKTo1250()
{
	static String cp(CsMJK_1250 + 128, 128);
	return cp;
}

static const byte CsMac1250[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,

	0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
	0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,

	0xc4,0x81,0x82,0xc9,0x84,0xd6,0xdc,0xe1,0x88,0xc8,0xe4,0xe8,0x8c,0x8d,0xe9,0x8f,
	0x90,0xcf,0xed,0xef,0x94,0x95,0x96,0xf3,0x98,0x99,0xf6,0x9b,0xfa,0xcc,0xec,0xfc,
	0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,
	0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbc,0xbe,0xbd,0xbe,0xbf,

	0xc0,0xc1,0xc2,0xc3,0xc4,0xd2,0xc6,0xc7,0xc8,0xc9,0xca,0xf2,0xcc,0xcd,0xce,0xcf,
	0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xd8,0xdc,0xdd,0xf8,0xdf,
	0xe0,0x8a,0xe2,0xe3,0x9a,0xe5,0xe6,0xc1,0x8d,0x9d,0xcd,0x8e,0x9e,0xed,0xd3,0xef,
	0xf0,0xd9,0xda,0xf9,0xf4,0xf5,0xf6,0xf7,0xdd,0xfd,0xfa,0xfb,0xfc,0xfd,0xfe,0xff,
};

const String& NlsMacTo1250()
{
	static String cp(CsMac1250 + 128, 128);
	return cp;
}

static const byte CsUpper1250[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,

	0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
	0x60,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x7b,0x7c,0x7d,0x7e,0x7f,

	0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
	0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8a,0x9b,0x8c,0x8d,0x8e,0x8f,
	0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,
	0xb0,0xb1,0xb2,0xa3,0xb4,0xb5,0xb6,0xb7,0xb8,0xa5,0xaa,0xbb,0xbc,0xbd,0xbc,0xaf,

	0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,
	0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf,
	0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,
	0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xf7,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xff,
};

static const byte CsLower1250[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,

	0x40,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x5b,0x5c,0x5d,0x5e,0x5f,
	0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,

	0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x9a,0x8b,0x9c,0x9d,0x9e,0x9f,
	0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
	0xa0,0xa1,0xa2,0xb3,0xa4,0xb9,0xa6,0xa7,0xa8,0xa9,0xba,0xab,0xac,0xad,0xae,0xbf,
	0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbe,0xbd,0xbe,0xbf,

	0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef,
	0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xd7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff,
	0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef,
	0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff,
};

static const byte CsAscii1250[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,

	0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
	0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,

	0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,'S' ,0x8b,'S' ,'T' ,'Z' ,'Z' ,
	0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,'s' ,0x9b,'s' ,'t' ,'z' ,'z' ,
	0xa0,0xa1,0xa2,'L' ,0xa4,'A' ,0xa6,0xa7,0xa8,0xa9,'S' ,0xab,0xac,0xad,0xae,'Z' ,
	0xb0,0xb1,0xb2,'l' ,0xb4,0xb5,0xb6,0xb7,0xb8,'a' ,'s' ,0xbb,'L' ,0xbd,'l' ,'z' ,

	'R' ,'A' ,'A' ,'A' ,'A' ,'L' ,'C' ,'C' ,'C' ,'E' ,'E' ,'E' ,'E' ,'I' ,'I' ,'D' ,
	'D' ,'N' ,'N' ,'O' ,'O' ,'O' ,'O' ,0xd7,'R' ,'U' ,'U' ,'U' ,'U' ,'Y' ,'T' ,0xdf,
	'r' ,'a' ,'a' ,'a' ,'a' ,'l' ,'c' ,'c' ,'c' ,'e' ,'e' ,'e' ,'e' ,'i' ,'i' ,'d' ,
	'd' ,'n' ,'n' ,'o' ,'o' ,'o' ,'o' ,0xf7,'r' ,'u' ,'u' ,'u' ,'u' ,'y' ,'t' ,0xff,
};

static const byte CsUpperAscii1250[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,

	0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
	0x60,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x7b,0x7c,0x7d,0x7e,0x7f,

	0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,'S' ,0x8b,'S' ,'T' ,'Z' ,'Z' ,
	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0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,

	0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,'s' ,0x8b,'s' ,'t' ,'z' ,'z' ,
	0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,'s' ,0x9b,'s' ,'t' ,'z' ,'z' ,
	0xa0,0xa1,0xa2,'l' ,0xa4,'a' ,0xa6,0xa7,0xa8,0xa9,'s' ,0xab,0xac,0xad,0xae,'z' ,
	0xb0,0xb1,0xb2,'l' ,0xb4,0xb5,0xb6,0xb7,0xb8,'a' ,'s' ,0xbb,'l' ,0xbd,'l' ,'z' ,

	'r' ,'a' ,'a' ,'a' ,'a' ,'l' ,'c' ,'c' ,'c' ,'e' ,'e' ,'e' ,'e' ,'i' ,'i' ,'d' ,
	'd' ,'n' ,'n' ,'o' ,'o' ,'o' ,'o' ,0xd7,'r' ,'u' ,'u' ,'u' ,'u' ,'y' ,'t' ,0xdf,
	'r' ,'a' ,'a' ,'a' ,'a' ,'l' ,'c' ,'c' ,'c' ,'e' ,'e' ,'e' ,'e' ,'i' ,'i' ,'d' ,
	'd' ,'n' ,'n' ,'o' ,'o' ,'o' ,'o' ,0xf7,'r' ,'u' ,'u' ,'u' ,'u' ,'y' ,'t' ,0xff,
};

static const bool CsIsLetter1250[256] =
{
	false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
	false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
	false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
	false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,

	false,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,
	true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,false,false,false,false,false,
	false,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,
	true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,false,false,false,false,false,

	false,false,false,false,false,false,false,false,false,false,true ,false,true ,true ,true ,true ,
	false,false,false,false,false,false,false,false,false,false,true ,false,true ,true ,true ,true ,
	false,false,false,true ,false,true ,false,false,false,false,true ,false,false,false,false,true ,
	false,false,false,true ,false,false,false,false,false,true ,true ,false,true ,false,true ,true ,

	true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,
	true ,true ,true ,true ,true ,true ,true ,false,true ,true ,true ,true ,true ,true ,true ,true ,
	true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,
	true ,true ,true ,true ,true ,true ,true ,false,true ,true ,true ,true ,true ,true ,true ,true ,
};

static const byte CsUpperLatin2[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,

	0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
	0x60,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x7B,0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,0x1F,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,

	0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
	0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,

	0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,
	0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
	0xA0,0x41,0xA2,0x4C,0xA4,0x4C,0x53,0xA7,0xA8,0x53,0x53,0x54,0x5A,0xAD,0x5A,0x5A,
	0xB0,0x61,0xB2,0x6C,0xB4,0x6C,0x73,0xB7,0xB8,0x73,0x73,0x74,0x7A,0xBD,0x7A,0x7A,

	0x52,0x41,0x41,0x41,0x41,0x4C,0x43,0x43,0x43,0x45,0x45,0x45,0x45,0x49,0x49,0x44,
	0x44,0x4E,0x4E,0x4F,0x4F,0x4F,0x4F,0xD7,0x52,0x55,0x55,0x55,0x55,0x59,0x54,0xDF,
	0x72,0x61,0x61,0x61,0x61,0x6C,0x63,0x63,0x63,0x65,0x65,0x65,0x65,0x69,0x69,0x64,
	0x64,0x6E,0x6E,0x6F,0x6F,0x6F,0x6F,0xF7,0x72,0x75,0x75,0x75,0x75,0x79,0x74,0xFF,
};

static const byte CsUpperAsciiLatin2[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,

	0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
	0x60,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x7B,0x7C,0x7D,0x7E,0x7F,

	0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,
	0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,

	0xA0,0x41,0xA2,0x4C,0xA4,0x4C,0x53,0xA7,0xA8,0x53,0x53,0x54,0x5A,0xAD,0x5A,0x5A,
	0xB0,0x41,0xB2,0x4C,0xB4,0x4C,0x53,0xB7,0xB8,0x53,0x53,0x54,0x5A,0xBD,0x5A,0x5A,

	0x52,0x41,0x41,0x41,0x41,0x4C,0x43,0x43,0x43,0x45,0x45,0x45,0x45,0x49,0x49,0x44,
	0x44,0x4E,0x4E,0x4F,0x4F,0x4F,0x4F,0xD7,0x52,0x55,0x55,0x55,0x55,0x59,0x54,0xDF,
	0x52,0x41,0x41,0x41,0x41,0x4C,0x43,0x43,0x43,0x45,0x45,0x45,0x45,0x49,0x49,0x44,
	0x44,0x4E,0x4E,0x4F,0x4F,0x4F,0x4F,0xF7,0x52,0x55,0x55,0x55,0x55,0x59,0x54,0xFF,
};

static const byte CsLowerAsciiLatin2[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,

	0x40,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x5B,0x5C,0x5D,0x5E,0x5F,
	0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,

	0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,
	0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
	0xA0,0x61,0xA2,0x6C,0xA4,0x6C,0x73,0xA7,0xA8,0x73,0x73,0x74,0x7A,0xAD,0x7A,0x7A,
	0xB0,0x61,0xB2,0x6C,0xB4,0x6C,0x73,0xB7,0xB8,0x73,0x73,0x74,0x7A,0xBD,0x7A,0x7A,

	0x72,0x61,0x61,0x61,0x61,0x6C,0x63,0x63,0x63,0x65,0x65,0x65,0x65,0x69,0x69,0x64,
	0x64,0x6E,0x6E,0x6F,0x6F,0x6F,0x6F,0xD7,0x72,0x75,0x75,0x75,0x75,0x79,0x74,0xDF,
	0x72,0x61,0x61,0x61,0x61,0x6C,0x63,0x63,0x63,0x65,0x65,0x65,0x65,0x69,0x69,0x64,
	0x64,0x6E,0x6E,0x6F,0x6F,0x6F,0x6F,0xF7,0x72,0x75,0x75,0x75,0x75,0x79,0x74,0xFF,
};

static const bool CsIsLetterLatin2[256] =
{
	false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
	false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
	false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
	false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,

	false,true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
	true, true, true, true, true, true, true, true, true, true, true, false,false,false,false,false,
	false,true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
	true, true, true, true, true, true, true, true, true, true, true, false,false,false,false,false,

	false,false,false,false,false,false,false,false,false,false,true, false,true, true, true, true,
	false,false,false,false,false,false,false,false,false,false,true, false,true, true, true, true,
	false,true, false,true, false,true, true, false,false,true, true, true, true, false,true, true,
	false,true, false,true, false,true, true, false,false,true, true, true, true, false,true, true,

	true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
	true, true, true, true, true, true, true, false,true, true, true, true, true, true, true, true,
	true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
	true, true, true, true, true, true, true, false,true, true, true, true, true, true, true, false,
};

#if defined(PLATFORM_WIN32)
int NlsDefaultCodePage = CP_1250;
#elif defined(PLATFORM_POSIX)
int NlsDefaultCodePage = CP_LATIN2;
#endif

const byte *NlsUpper(byte charset)
{
	switch(charset ? charset : NlsDefaultCodePage)
	{
	case CP_1250:   return CsUpper1250;
	case CP_LATIN2: return CsUpperLatin2;
	}
	return NULL;
}

const byte *NlsLower(byte charset)
{
	switch(charset ? charset : NlsDefaultCodePage)
	{
	case CP_1250:   return CsLower1250;
	case CP_LATIN2: return CsLowerLatin2;
	}
	return NULL;
}

const byte *NlsAscii(byte charset)
{
	switch(charset ? charset : NlsDefaultCodePage)
	{
	case CP_1250:   return CsAscii1250;
	case CP_LATIN2: return CsAsciiLatin2;
	}
	return NULL;
}

const byte *NlsUpperAscii(byte charset)
{
	switch(charset ? charset : NlsDefaultCodePage)
	{
	case CP_1250:   return CsUpperAscii1250;
	case CP_LATIN2: return CsUpperAsciiLatin2;
	}
	return NULL;
}

const byte *NlsLowerAscii(byte charset)
{
	switch(charset ? charset : NlsDefaultCodePage)
	{
	case CP_1250:   return CsLowerAscii1250;
	case CP_LATIN2: return CsLowerAsciiLatin2;
	}
	return NULL;
}

const bool *NlsLetter(byte charset)
{
	switch(charset ? charset : NlsDefaultCodePage)
	{
	case CP_1250:   return CsIsLetter1250;
	case CP_LATIN2: return CsIsLetterLatin2;
	}
	return NULL;
}

String NlsGetIndexLetter(const char *s, int language, byte charset)
{
	char temp[3];
	temp[0] = temp[1] = temp[2] = 0;
	if(NlsIsLetter(*s, charset))
	{
		temp[0] = NlsToUpper(*s, charset);
		if(NlsIsLetter(s[1], charset))
			temp[1] = NlsToLower(s[1], charset);
		if(temp[0] != 'C' || temp[1] != 'h')
			temp[1] = 0;
		switch(NlsToUpperAscii(*s, charset))
		{
		case 'A': case 'E': case 'I': case 'N':
		case 'O': case 'T': case 'U': case 'Y':
			temp[0] = NlsToAscii(temp[0], charset);
			break;
		}
	}
	return temp;
}

int NlsCompare(const char *s1, const char *s2, int language, byte charset)
{
	const byte *csa = NlsAscii(charset);
	const byte *csu = NlsUpper(charset);

	byte c1, c2;
	int  little = 0, middle = 0;

	do
	{
		int u1, u2, i1, i2;

		c1 = *s1++;
		c2 = *s2++;
		if((c1 == 'C' || c1 == 'c') && (*s1 == 'H' || *s1 == 'h'))
		{ 
			i1 = 'H';
			u1 = 256;
			s1++;
		}
		else
			i1 = csa[u1 = csu[c1]];
		if((c2 == 'C' || c2 == 'c') && (*s2 == 'H' || *s2 == 'h'))
		{ 
			i2 = 'H';
			u2 = 256;
			s2++;
		}
		else
			i2 = csa[u2 = csu[c2]];

		if(i1 != i2)
			return i1 >= i2 ? 1 : -1; 
		if(u1 != u2) 
			switch(i1)
			{
			case 'A': case 'E': case 'I': case 'N':
			case 'O': case 'T': case 'U': case 'Y':
				if(middle == 0)
					middle = u1 - u2;
				continue;
			default:
				return u1 >= u2 ? 1 : -1;
			}
		if(c1 != c2) 
		{
			if(little == 0)
				little = (u1 != c1) - (u2 != c2);
		}
	}
	while(c1 != 0 && c2 != 0);
	little += 4 * middle;
	return little > 0 ? 1 : little < 0 ? -1 : 0;
}

int NlsCompare(const wchar *s1, const wchar *s2, int language)
{
	byte cs = GetLangCharset(language);
	return NlsCompare(FromUnicode(s1, cs), FromUnicode(s2, cs), language, cs);
}

int NlsNumCompare(const char *s1, const char *s2, int language, byte charset)
{
	const byte *csa = NlsAscii(charset);
	const byte *csu = NlsUpper(charset);

	byte c1, c2;
	int  little = 0, middle = 0;
	const char *p1 = s1, *p2 = s2;

	do
	{
		int u1, u2, i1, i2;

		c1 = *s1++;
		c2 = *s2++;
		if((c1 == 'C' || c1 == 'c') && (*s1 == 'H' || *s1 == 'h'))
		{ 
			i1 = 'H';
			u1 = 256;
			s1++;
		}
		else
			i1 = csa[u1 = csu[c1]];
		if((c2 == 'C' || c2 == 'c') && (*s2 == 'H' || *s2 == 'h'))
		{ 
			i2 = 'H';
			u2 = 256;
			s2++;
		}
		else
			i2 = csa[u2 = csu[c2]];

		if(i1 != i2)
		{ 
			if((IsDigit(i1) || IsDigit(i2))
				&& s1 > p1 && s2 > p2 && IsDigit(s1[-1]) && IsDigit(s2[-1]))
			{
				while(s1 > p1 && IsDigit(s1[-1]))
					s1--;
				while(s2 > p2 && IsDigit(s2[-1]))
					s2--;
				int d = atoi(s1) - atoi(s2);
				return d >= 0 ? 1 : -1;
			}
			return i1 >= i2 ? 1 : -1; 
		}
		if(u1 != u2) 
			switch(i1)
			{
			case 'A': case 'E': case 'I': case 'N':
			case 'O': case 'T': case 'U': case 'Y':
				if(middle == 0)
					middle = u1 - u2;
				continue;
			default:
				return u1 >= u2 ? 1 : -1;
			}
		if(c1 != c2) 
		{
			if(little == 0)

				little = (u1 != c1) - (u2 != c2);
		}
	}
	while(c1 != 0 && c2 != 0);
	little += 4 * middle;
	return little > 0 ? 1 : little < 0 ? -1 : 0;
}

int NlsNumCompare(const wchar *s1, const wchar *s2, int language)
{
	byte cs = GetLangCharset(language);
	return NlsNumCompare(FromUnicode(s1, cs), FromUnicode(s2, cs), language, cs);
}

String NlsMakeAscii(const char *s, byte charset, int count)
{
	if(count < 0)
		count = strlen(s);
	const byte *asc = NlsAscii(charset);
	String temp;
	for(char *p = temp.GetBuffer(count), *e = p + count; p < e;)
		*p++ = asc[(byte)*s++];
	temp.ReleaseBuffer(count);
	return temp;
}

String NlsMakeUpper(const char *s, byte charset, int count)
{
	if(count < 0)
		count = strlen(s);
	const byte *upp = NlsUpper(charset);
	String temp;
	for(char *p = temp.GetBuffer(count), *e = p + count; p < e;)
		*p++ = upp[(byte)*s++];
	temp.ReleaseBuffer(count);
	return temp;
}

String NlsMakeLower(const char *s, byte charset, int count)
{
	if(count < 0)
		count = strlen(s);
	const byte *low = NlsLower(charset);
	String temp;
	for(char *p = temp.GetBuffer(count), *e = p + count; p < e;)
		*p++ = low[(byte)*s++];
	temp.ReleaseBuffer(count);
	return temp;
}

String NlsToUpperAscii(const char *s, byte charset, int count)
{
	if(count < 0)
		count = strlen(s);
	const byte *upa = NlsUpperAscii(charset);
	String temp;
	for(char *p = temp.GetBuffer(count), *e = p + count; p < e;)
		*p++ = upa[(byte)*s++];
	temp.ReleaseBuffer(count);
	return temp;
}

String NlsToLowerAscii(const char *s, byte charset, int count)
{
	if(count < 0)
		count = strlen(s);
	const byte *lwa = NlsLowerAscii(charset);
	String temp;
	for(char *p = temp.GetBuffer(count), *e = p + count; p < e;)
		*p++ = lwa[(byte)*s++];
	temp.ReleaseBuffer(count);
	return temp;
}

bool NlsContainsNational(const char *s, byte charset, int count)
{
	if(count < 0)
		count = strlen(s);
	const byte *csa = NlsAscii(charset);
	for(const char *e = s + count; s < e; s++)
		if((byte)*s != csa[(byte)*s])
			return true;
	return false;
}

bool NlsLike::Set(const char *templ, byte cs)
{
	charset = cs;
	raw_templ = 0;
	cvt = 0;
	exclude_ch = false;
	always_true = (*templ == 0);
	if(always_true)
		return true;
	if((*templ == '.' && templ[1] != 0 && *++templ != '.') || NlsContainsNational(templ, charset))
	{
		if(charset == LNG_CZECH)
			exclude_ch = (ToUpper(*templ) == 'C' && templ[1] == 0);
		cvt = NlsUpper(charset);
	}
	else
		cvt = NlsUpperAscii(charset);
	raw_templ = templ;
	return false;
}

bool NlsLike::Matches(const char *s) const
{
	if(always_true)
		return true;
	if(exclude_ch && *s && (s[1] == 'h' || s[1] == 'H'))
		return false;
	return RawMatches(s, raw_templ);
}

bool NlsLike::RawMatches(const char *s, const char *templ) const
{
	for(;;)
		switch(*templ++)
		{
		case 0: return true;
		case '.': if(*templ == 0) return *s == 0; 
		case '?': if(*s++ == 0) return false; break;
		case '*':
			do
				if(RawMatches(s, templ))
					return true;
			while(*s++);
			return false;

		default:
			if(cvt[(byte)templ[-1]] != cvt[(byte)*s++])
				return false;
			break;
		}
}

#endif
//////////////////////////////////////////////////////////////////////
// nls: NLS routines.

#if 0

#include "TCore.h"

//////////////////////////////////////////////////////////////////////
// 1250 code page tables

static const byte CsLatin2_1250[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
	0x20,0x21,0x22,0x23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8,0xF8,0x5F,0x20,

/*
	0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,
	0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
	0xA0,0xA5,0xA2,0xA3,0xA4,0xBC,0x8C,0xA7,0xA8,0x8A,0xAA,0x8D,0x8F,0xAD,0x8E,0xAF,
	0xB0,0xB9,0xB2,0xB3,0xB4,0xBE,0x9C,0xA1,0xB8,0x9A,0xBA,0x9D,0x9F,0xBD,0x9E,0xBF,

	0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,
	0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
	0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,
	0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xB7,
*/
};

const String& NlsLatin2To1250()
{
	static String cp(CsLatin2_1250 + 128, 128);
	return cp;
}

//////////////////////////////////////////////////////////////////////

static const byte CsMJK_1250[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,

	0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
	0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,

	0xC8,0xFC,0xE9,0xEF,0xE4,0xCF,0x8D,0xE8,0xEC,0xCC,0xC5,0xCD,0xBE,0xE5,0xC4,0xC1,
	0xC9,0x9E,0x8E,0xF4,0xF6,0xD3,0xF9,0xDA,0xFD,0xD6,0xDC,0x8A,0xBC,0xDD,0xD8,0x9D,
	0xE1,0xED,0xF3,0xFA,0xF2,0xD2,0xD9,0xD4,0x9A,0xF8,0xE0,0xC0,0xAC,0xA7,0xBB,0xAB,
	0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,

	0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,
	0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
	0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xB5,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,
	0xF0,0xB1,0xF2,0xF3,0xF4,0xF5,0xF7,0xF7,0xB0,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
};

const String& NlsMJKTo1250()
{
	static String cp(CsMJK_1250 + 128, 128);
	return cp;
}

//////////////////////////////////////////////////////////////////////

static const byte CsMac1250[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,

	0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
	0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,

	0xc4,0x81,0x82,0xc9,0x84,0xd6,0xdc,0xe1,0x88,0xc8,0xe4,0xe8,0x8c,0x8d,0xe9,0x8f,
	0x90,0xcf,0xed,0xef,0x94,0x95,0x96,0xf3,0x98,0x99,0xf6,0x9b,0xfa,0xcc,0xec,0xfc,
	0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,
	0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbc,0xbe,0xbd,0xbe,0xbf,

	0xc0,0xc1,0xc2,0xc3,0xc4,0xd2,0xc6,0xc7,0xc8,0xc9,0xca,0xf2,0xcc,0xcd,0xce,0xcf,
	0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xd8,0xdc,0xdd,0xf8,0xdf,
	0xe0,0x8a,0xe2,0xe3,0x9a,0xe5,0xe6,0xc1,0x8d,0x9d,0xcd,0x8e,0x9e,0xed,0xd3,0xef,
	0xf0,0xd9,0xda,0xf9,0xf4,0xf5,0xf6,0xf7,0xdd,0xfd,0xfa,0xfb,0xfc,0xfd,0xfe,0xff,
};

const String& NlsMacTo1250()
{
	static String cp(CsMac1250 + 128, 128);
	return cp;
}

//////////////////////////////////////////////////////////////////////

static const byte CsUpper1250[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,

	0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
	0x60,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x7b,0x7c,0x7d,0x7e,0x7f,

	0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
	0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8a,0x9b,0x8c,0x8d,0x8e,0x8f,
	0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,
	0xb0,0xb1,0xb2,0xa3,0xb4,0xb5,0xb6,0xb7,0xb8,0xa5,0xaa,0xbb,0xbc,0xbd,0xbc,0xaf,

	0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,
	0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf,
	0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,
	0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xf7,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xff,
};

//////////////////////////////////////////////////////////////////////

static const byte CsLower1250[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,

	0x40,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x5b,0x5c,0x5d,0x5e,0x5f,
	0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,

	0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x9a,0x8b,0x9c,0x9d,0x9e,0x9f,
	0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
	0xa0,0xa1,0xa2,0xb3,0xa4,0xb9,0xa6,0xa7,0xa8,0xa9,0xba,0xab,0xac,0xad,0xae,0xbf,
	0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbe,0xbd,0xbe,0xbf,

	0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef,
	0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xd7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff,
	0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef,
	0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff,
};

//////////////////////////////////////////////////////////////////////

static const byte CsAscii1250[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,

	0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f,
	0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,

	0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,'S' ,0x8b,'S' ,'T' ,'Z' ,'Z' ,
	0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,'s' ,0x9b,'s' ,'t' ,'z' ,'z' ,
	0xa0,0xa1,0xa2,'L' ,0xa4,'A' ,0xa6,0xa7,0xa8,0xa9,'S' ,0xab,0xac,0xad,0xae,'Z' ,
	0xb0,0xb1,0xb2,'l' ,0xb4,0xb5,0xb6,0xb7,0xb8,'a' ,'s' ,0xbb,'L' ,0xbd,'l' ,'z' ,

	'R' ,'A' ,'A' ,'A' ,'A' ,'L' ,'C' ,'C' ,'C' ,'E' ,'E' ,'E' ,'E' ,'I' ,'I' ,'D' ,
	'D' ,'N' ,'N' ,'O' ,'O' ,'O' ,'O' ,0xd7,'R' ,'U' ,'U' ,'U' ,'U' ,'Y' ,'T' ,0xdf,
	'r' ,'a' ,'a' ,'a' ,'a' ,'l' ,'c' ,'c' ,'c' ,'e' ,'e' ,'e' ,'e' ,'i' ,'i' ,'d' ,
	'd' ,'n' ,'n' ,'o' ,'o' ,'o' ,'o' ,0xf7,'r' ,'u' ,'u' ,'u' ,'u' ,'y' ,'t' ,0xff,
};

//////////////////////////////////////////////////////////////////////

static const byte CsUpperAscii1250[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
	0x10,0x11,0x12,0x13,0x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,'I' ,'I' ,'D' ,
	'D' ,'N' ,'N' ,'O' ,'O' ,'O' ,'O' ,0xf7,'R' ,'U' ,'U' ,'U' ,'U' ,'Y' ,'T' ,0xff,
};

//////////////////////////////////////////////////////////////////////

static const byte CsLowerAscii1250[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f,

	0x40,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x5b,0x5c,0x5d,0x5e,0x5f,
	0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f,

	0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,'s' ,0x8b,'s' ,'t' ,'z' ,'z' ,
	0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,'s' ,0x9b,'s' ,'t' ,'z' ,'z' ,
	0xa0,0xa1,0xa2,'l' ,0xa4,'a' ,0xa6,0xa7,0xa8,0xa9,'s' ,0xab,0xac,0xad,0xae,'z' ,
	0xb0,0xb1,0xb2,'l' ,0xb4,0xb5,0xb6,0xb7,0xb8,'a' ,'s' ,0xbb,'l' ,0xbd,'l' ,'z' ,

	'r' ,'a' ,'a' ,'a' ,'a' ,'l' ,'c' ,'c' ,'c' ,'e' ,'e' ,'e' ,'e' ,'i' ,'i' ,'d' ,
	'd' ,'n' ,'n' ,'o' ,'o' ,'o' ,'o' ,0xd7,'r' ,'u' ,'u' ,'u' ,'u' ,'y' ,'t' ,0xdf,
	'r' ,'a' ,'a' ,'a' ,'a' ,'l' ,'c' ,'c' ,'c' ,'e' ,'e' ,'e' ,'e' ,'i' ,'i' ,'d' ,
	'd' ,'n' ,'n' ,'o' ,'o' ,'o' ,'o' ,0xf7,'r' ,'u' ,'u' ,'u' ,'u' ,'y' ,'t' ,0xff,
};

//////////////////////////////////////////////////////////////////////

static const bool CsIsLetter1250[256] =
{
	false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
	false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
	false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
	false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,

	false,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,
	true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,false,false,false,false,false,
	false,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,
	true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,false,false,false,false,false,

	false,false,false,false,false,false,false,false,false,false,true ,false,true ,true ,true ,true ,
	false,false,false,false,false,false,false,false,false,false,true ,false,true ,true ,true ,true ,
	false,false,false,true ,false,true ,false,false,false,false,true ,false,false,false,false,true ,
	false,false,false,true ,false,false,false,false,false,true ,true ,false,true ,false,true ,true ,

	true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,
	true ,true ,true ,true ,true ,true ,true ,false,true ,true ,true ,true ,true ,true ,true ,true ,
	true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,true ,
	true ,true ,true ,true ,true ,true ,true ,false,true ,true ,true ,true ,true ,true ,true ,true ,
};

//////////////////////////////////////////////////////////////////////
// Latin2 code page tables

static const byte CsUpperLatin2[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,

	0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
	0x60,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x7B,0x7C,0x7D,0x7E,0x7F,

	0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,
	0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
	0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,
	0xB0,0xA1,0xB2,0xA3,0xB4,0xA5,0xA6,0xB7,0xB8,0xA9,0xAA,0xAB,0xAC,0xBD,0xAE,0xAF,

	0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,
	0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,
	0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,
	0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF,
};

static const byte CsLowerLatin2[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,

	0x40,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x5B,0x5C,0x5D,0x5E,0x5F,
	0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,

	0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,
	0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
	0xA0,0xB1,0xA2,0xB3,0xA4,0xB5,0xB6,0xA7,0xA8,0xB9,0xBA,0xBB,0xBC,0xAD,0xBE,0xBF,
	0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,

	0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,
	0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xD7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
	0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,
	0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,
};

static const byte CsAsciiLatin2[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,

	0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
	0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,

	0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,
	0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
	0xA0,0x41,0xA2,0x4C,0xA4,0x4C,0x53,0xA7,0xA8,0x53,0x53,0x54,0x5A,0xAD,0x5A,0x5A,
	0xB0,0x61,0xB2,0x6C,0xB4,0x6C,0x73,0xB7,0xB8,0x73,0x73,0x74,0x7A,0xBD,0x7A,0x7A,

	0x52,0x41,0x41,0x41,0x41,0x4C,0x43,0x43,0x43,0x45,0x45,0x45,0x45,0x49,0x49,0x44,
	0x44,0x4E,0x4E,0x4F,0x4F,0x4F,0x4F,0xD7,0x52,0x55,0x55,0x55,0x55,0x59,0x54,0xDF,
	0x72,0x61,0x61,0x61,0x61,0x6C,0x63,0x63,0x63,0x65,0x65,0x65,0x65,0x69,0x69,0x64,
	0x64,0x6E,0x6E,0x6F,0x6F,0x6F,0x6F,0xF7,0x72,0x75,0x75,0x75,0x75,0x79,0x74,0xFF,
};

static const byte CsUpperAsciiLatin2[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,

	0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
	0x60,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
	0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x7B,0x7C,0x7D,0x7E,0x7F,

	0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,
	0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,

	0xA0,0x41,0xA2,0x4C,0xA4,0x4C,0x53,0xA7,0xA8,0x53,0x53,0x54,0x5A,0xAD,0x5A,0x5A,
	0xB0,0x41,0xB2,0x4C,0xB4,0x4C,0x53,0xB7,0xB8,0x53,0x53,0x54,0x5A,0xBD,0x5A,0x5A,

	0x52,0x41,0x41,0x41,0x41,0x4C,0x43,0x43,0x43,0x45,0x45,0x45,0x45,0x49,0x49,0x44,
	0x44,0x4E,0x4E,0x4F,0x4F,0x4F,0x4F,0xD7,0x52,0x55,0x55,0x55,0x55,0x59,0x54,0xDF,
	0x52,0x41,0x41,0x41,0x41,0x4C,0x43,0x43,0x43,0x45,0x45,0x45,0x45,0x49,0x49,0x44,
	0x44,0x4E,0x4E,0x4F,0x4F,0x4F,0x4F,0xF7,0x52,0x55,0x55,0x55,0x55,0x59,0x54,0xFF,
};

static const byte CsLowerAsciiLatin2[256] =
{
	0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
	0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
	0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
	0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,

	0x40,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x5B,0x5C,0x5D,0x5E,0x5F,
	0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,
	0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,

	0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,
	0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,
	0xA0,0x61,0xA2,0x6C,0xA4,0x6C,0x73,0xA7,0xA8,0x73,0x73,0x74,0x7A,0xAD,0x7A,0x7A,
	0xB0,0x61,0xB2,0x6C,0xB4,0x6C,0x73,0xB7,0xB8,0x73,0x73,0x74,0x7A,0xBD,0x7A,0x7A,

	0x72,0x61,0x61,0x61,0x61,0x6C,0x63,0x63,0x63,0x65,0x65,0x65,0x65,0x69,0x69,0x64,
	0x64,0x6E,0x6E,0x6F,0x6F,0x6F,0x6F,0xD7,0x72,0x75,0x75,0x75,0x75,0x79,0x74,0xDF,
	0x72,0x61,0x61,0x61,0x61,0x6C,0x63,0x63,0x63,0x65,0x65,0x65,0x65,0x69,0x69,0x64,
	0x64,0x6E,0x6E,0x6F,0x6F,0x6F,0x6F,0xF7,0x72,0x75,0x75,0x75,0x75,0x79,0x74,0xFF,
};

static const bool CsIsLetterLatin2[256] =
{
	false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
	false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
	false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
	false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,

	false,true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
	true, true, true, true, true, true, true, true, true, true, true, false,false,false,false,false,
	false,true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
	true, true, true, true, true, true, true, true, true, true, true, false,false,false,false,false,

	false,false,false,false,false,false,false,false,false,false,true, false,true, true, true, true,
	false,false,false,false,false,false,false,false,false,false,true, false,true, true, true, true,
	false,true, false,true, false,true, true, false,false,true, true, true, true, false,true, true,
	false,true, false,true, false,true, true, false,false,true, true, true, true, false,true, true,

	true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
	true, true, true, true, true, true, true, false,true, true, true, true, true, true, true, true,
	true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true,
	true, true, true, true, true, true, true, false,true, true, true, true, true, true, true, false,
};

//////////////////////////////////////////////////////////////////////
// platform-default code page tables

#if defined(PLATFORM_WIN32)
int NlsDefaultCodePage = CP_1250;
#elif defined(PLATFORM_POSIX)
int NlsDefaultCodePage = CP_LATIN2;
#endif

//////////////////////////////////////////////////////////////////////

const byte *NlsUpper(byte charset)
{
	switch(charset ? charset : NlsDefaultCodePage)
	{
	case CP_1250:   return CsUpper1250;
	case CP_LATIN2: return CsUpperLatin2;
	}
	return NULL;
}

//////////////////////////////////////////////////////////////////////

const byte *NlsLower(byte charset)
{
	switch(charset ? charset : NlsDefaultCodePage)
	{
	case CP_1250:   return CsLower1250;
	case CP_LATIN2: return CsLowerLatin2;
	}
	return NULL;
}

//////////////////////////////////////////////////////////////////////

const byte *NlsAscii(byte charset)
{
	switch(charset ? charset : NlsDefaultCodePage)
	{
	case CP_1250:   return CsAscii1250;
	case CP_LATIN2: return CsAsciiLatin2;
	}
	return NULL;
}

//////////////////////////////////////////////////////////////////////

const byte *NlsUpperAscii(byte charset)
{
	switch(charset ? charset : NlsDefaultCodePage)
	{
	case CP_1250:   return CsUpperAscii1250;
	case CP_LATIN2: return CsUpperAsciiLatin2;
	}
	return NULL;
}

//////////////////////////////////////////////////////////////////////

const byte *NlsLowerAscii(byte charset)
{
	switch(charset ? charset : NlsDefaultCodePage)
	{
	case CP_1250:   return CsLowerAscii1250;
	case CP_LATIN2: return CsLowerAsciiLatin2;
	}
	return NULL;
}

//////////////////////////////////////////////////////////////////////

const bool *NlsLetter(byte charset)
{
	switch(charset ? charset : NlsDefaultCodePage)
	{
	case CP_1250:   return CsIsLetter1250;
	case CP_LATIN2: return CsIsLetterLatin2;
	}
	return NULL;
}

//////////////////////////////////////////////////////////////////////
// todo: true international index letter (this is Czech-specific)

String NlsGetIndexLetter(const char *s, int language, byte charset)
{
	char temp[3];
	temp[0] = temp[1] = temp[2] = 0;
	if(NlsIsLetter(*s, charset))
	{
		temp[0] = NlsToUpper(*s, charset);
		if(NlsIsLetter(s[1], charset))
			temp[1] = NlsToLower(s[1], charset);
		if(temp[0] != 'C' || temp[1] != 'h')
			temp[1] = 0;
		switch(NlsToUpperAscii(*s, charset))
		{
		case 'A': case 'E': case 'I': case 'N':
		case 'O': case 'T': case 'U': case 'Y':
			temp[0] = NlsToAscii(temp[0], charset);
			break;
		}
	}
	return temp;
}

//////////////////////////////////////////////////////////////////////
// todo: true international comparison (this is Czech-specific)

int NlsCompare(const char *s1, const char *s2, int language, byte charset)
{
	const byte *csa = NlsAscii(charset);
	const byte *csu = NlsUpper(charset);

	byte c1, c2;
	int  little = 0, middle = 0;

	do
	{
		int u1, u2, i1, i2;

		c1 = *s1++;
		c2 = *s2++;
		if((c1 == 'C' || c1 == 'c') && (*s1 == 'H' || *s1 == 'h'))
		{ // CH
			i1 = 'H';
			u1 = 256;
			s1++;
		}
		else
			i1 = csa[u1 = csu[c1]];
		if((c2 == 'C' || c2 == 'c') && (*s2 == 'H' || *s2 == 'h'))
		{ // CH
			i2 = 'H';
			u2 = 256;
			s2++;
		}
		else
			i2 = csa[u2 = csu[c2]];

		if(i1 != i2)
			return i1 >= i2 ? 1 : -1; // large difference
		if(u1 != u2) // different diacritics
			switch(i1)
			{
			case 'A': case 'E': case 'I': case 'N':
			case 'O': case 'T': case 'U': case 'Y':
				if(middle == 0)
					middle = u1 - u2;
				continue;
			default:
				return u1 >= u2 ? 1 : -1;
			}
		if(c1 != c2) // different case
		{
			if(little == 0)
				little = (u1 != c1) - (u2 != c2);
		}
	}
	while(c1 != 0 && c2 != 0);
	little += 4 * middle;
	return little > 0 ? 1 : little < 0 ? -1 : 0;
}

//////////////////////////////////////////////////////////////////////
// todo: true international comparison (this is Czech-specific)

int NlsCompare(const wchar *s1, const wchar *s2, int language)
{
	byte cs = GetLangCharset(language);
	return NlsCompare(FromUnicode(s1, cs), FromUnicode(s2, cs), language, cs);
}
/*
	const wchar *csa = NlsAscii(charset);
	const wchar *csu = NlsUpper(charset);

	byte c1, c2;
	int  little = 0, middle = 0;

	do
	{
		int u1, u2, i1, i2;

		c1 = *s1++;
		c2 = *s2++;
		if((c1 == 'C' || c1 == 'c') && (*s1 == 'H' || *s1 == 'h'))
		{ // CH
			i1 = 'H';
			u1 = 256;
			s1++;
		}
		else
			i1 = csa[u1 = csu[c1]];
		if((c2 == 'C' || c2 == 'c') && (*s2 == 'H' || *s2 == 'h'))
		{ // CH
			i2 = 'H';
			u2 = 256;
			s2++;
		}
		else
			i2 = csa[u2 = csu[c2]];

		if(i1 != i2)
			return i1 >= i2 ? 1 : -1; // large difference
		if(u1 != u2) // different diacritics
			switch(i1)
			{
			case 'A': case 'E': case 'I': case 'N':
			case 'O': case 'T': case 'U': case 'Y':
				if(middle == 0)
					middle = u1 - u2;
				continue;
			default:
				return u1 >= u2 ? 1 : -1;
			}
		if(c1 != c2) // different case
		{
			if(little == 0)
				little = (u1 != c1) - (u2 != c2);
		}
	}
	while(c1 != 0 && c2 != 0);
	little += 4 * middle;
	return little > 0 ? 1 : little < 0 ? -1 : 0;
}
*/

//////////////////////////////////////////////////////////////////////
// todo: true international comparison (this is Czech-specific)

int NlsNumCompare(const char *s1, const char *s2, int language, byte charset)
{
	const byte *csa = NlsAscii(charset);
	const byte *csu = NlsUpper(charset);

	byte c1, c2;
	int  little = 0, middle = 0;
	const char *p1 = s1, *p2 = s2;

	do
	{
		int u1, u2, i1, i2;

		c1 = *s1++;
		c2 = *s2++;
		if((c1 == 'C' || c1 == 'c') && (*s1 == 'H' || *s1 == 'h'))
		{ // CH
			i1 = 'H';
			u1 = 256;
			s1++;
		}
		else
			i1 = csa[u1 = csu[c1]];
		if((c2 == 'C' || c2 == 'c') && (*s2 == 'H' || *s2 == 'h'))
		{ // CH
			i2 = 'H';
			u2 = 256;
			s2++;
		}
		else
			i2 = csa[u2 = csu[c2]];

		if(i1 != i2)
		{ // large difference; test numerical difference
			if((IsDigit(i1) || IsDigit(i2))
				&& s1 > p1 && s2 > p2 && IsDigit(s1[-1]) && IsDigit(s2[-1]))
			{
				while(s1 > p1 && IsDigit(s1[-1]))
					s1--;
				while(s2 > p2 && IsDigit(s2[-1]))
					s2--;
				int d = atoi(s1) - atoi(s2);
				return d >= 0 ? 1 : -1;
			}
			return i1 >= i2 ? 1 : -1; // large difference
		}
		if(u1 != u2) // different diacritics
			switch(i1)
			{
			case 'A': case 'E': case 'I': case 'N':
			case 'O': case 'T': case 'U': case 'Y':
				if(middle == 0)
					middle = u1 - u2;
				continue;
			default:
				return u1 >= u2 ? 1 : -1;
			}
		if(c1 != c2) // different case
		{
			if(little == 0)

				little = (u1 != c1) - (u2 != c2);
		}
	}
	while(c1 != 0 && c2 != 0);
	little += 4 * middle;
	return little > 0 ? 1 : little < 0 ? -1 : 0;
}

//////////////////////////////////////////////////////////////////////

int NlsNumCompare(const wchar *s1, const wchar *s2, int language)
{
	byte cs = GetLangCharset(language);
	return NlsNumCompare(FromUnicode(s1, cs), FromUnicode(s2, cs), language, cs);
}

//////////////////////////////////////////////////////////////////////

String NlsMakeAscii(const char *s, byte charset, int count)
{
	if(count < 0)
		count = strlen(s);
	const byte *asc = NlsAscii(charset);
	String temp;
	for(char *p = temp.GetBuffer(count), *e = p + count; p < e;)
		*p++ = asc[(byte)*s++];
	temp.ReleaseBuffer(count);
	return temp;
}

//////////////////////////////////////////////////////////////////////

String NlsMakeUpper(const char *s, byte charset, int count)
{
	if(count < 0)
		count = strlen(s);
	const byte *upp = NlsUpper(charset);
	String temp;
	for(char *p = temp.GetBuffer(count), *e = p + count; p < e;)
		*p++ = upp[(byte)*s++];
	temp.ReleaseBuffer(count);
	return temp;
}

//////////////////////////////////////////////////////////////////////

String NlsMakeLower(const char *s, byte charset, int count)
{
	if(count < 0)
		count = strlen(s);
	const byte *low = NlsLower(charset);
	String temp;
	for(char *p = temp.GetBuffer(count), *e = p + count; p < e;)
		*p++ = low[(byte)*s++];
	temp.ReleaseBuffer(count);
	return temp;
}

//////////////////////////////////////////////////////////////////////

String NlsToUpperAscii(const char *s, byte charset, int count)
{
	if(count < 0)
		count = strlen(s);
	const byte *upa = NlsUpperAscii(charset);
	String temp;
	for(char *p = temp.GetBuffer(count), *e = p + count; p < e;)
		*p++ = upa[(byte)*s++];
	temp.ReleaseBuffer(count);
	return temp;
}

//////////////////////////////////////////////////////////////////////

String NlsToLowerAscii(const char *s, byte charset, int count)
{
	if(count < 0)
		count = strlen(s);
	const byte *lwa = NlsLowerAscii(charset);
	String temp;
	for(char *p = temp.GetBuffer(count), *e = p + count; p < e;)
		*p++ = lwa[(byte)*s++];
	temp.ReleaseBuffer(count);
	return temp;
}

//////////////////////////////////////////////////////////////////////

bool NlsContainsNational(const char *s, byte charset, int count)
{
	if(count < 0)
		count = strlen(s);
	const byte *csa = NlsAscii(charset);
	for(const char *e = s + count; s < e; s++)
		if((byte)*s != csa[(byte)*s])
			return true;
	return false;
}

//////////////////////////////////////////////////////////////////////
// NlsLike::

bool NlsLike::Set(const char *templ, byte cs)
{
	charset = cs;
	raw_templ = 0;
	cvt = 0;
	exclude_ch = false;
	always_true = (*templ == 0);
	if(always_true)
		return true;
	if((*templ == '.' && templ[1] != 0 && *++templ != '.') || NlsContainsNational(templ, charset))
	{
		if(charset == LNG_CZECH)
			exclude_ch = (ToUpper(*templ) == 'C' && templ[1] == 0);
		cvt = NlsUpper(charset);
	}
	else
		cvt = NlsUpperAscii(charset);
	raw_templ = templ;
	return false;
}

//////////////////////////////////////////////////////////////////////

bool NlsLike::Matches(const char *s) const
{
	if(always_true)
		return true;
	if(exclude_ch && *s && (s[1] == 'h' || s[1] == 'H'))
		return false;
	return RawMatches(s, raw_templ);
}

//////////////////////////////////////////////////////////////////////

bool NlsLike::RawMatches(const char *s, const char *templ) const
{
	for(;;)
		switch(*templ++)
		{
		case 0: return true;
		case '.': if(*templ == 0) return *s == 0; // force end of string
		case '?': if(*s++ == 0) return false; break;
		case '*':
			do
				if(RawMatches(s, templ))
					return true;
			while(*s++);
			return false;

		default:
			if(cvt[(byte)templ[-1]] != cvt[(byte)*s++])
				return false;
			break;
		}
}

//////////////////////////////////////////////////////////////////////

#endif
