//---------------------------------------------------------------------------

#include "ascii.h"

//Из руского DOC в юникод 
std::string fromDOStoASCII(const std::string str)
{
	std::string rez(str.length(), '\0');
	for(size_t i=0;i<str.length();i++)
	{
		switch ((char)str[i])
		{
			case (char)0x00: rez[i]=0x00; break;
			case (char)0x01: rez[i]=0x01; break;
			case (char)0x02: rez[i]='?'; break;
			case (char)0x03: rez[i]='?'; break;
			case (char)0x04: rez[i]='?'; break;
			case (char)0x05: rez[i]='?'; break;
			case (char)0x06: rez[i]='?'; break;
			case (char)0x07: rez[i]='?'; break;
			case (char)0x08: rez[i]='?'; break;
			case (char)0x09: rez[i]='?'; break;
			case (char)0x0a: rez[i]='?'; break;
			case (char)0x0b: rez[i]='?'; break;
			case (char)0x0c: rez[i]='?'; break;
			case (char)0x0d: rez[i]='?'; break;
			case (char)0x0e: rez[i]='?'; break;
			case (char)0x0f: rez[i]='?'; break;

			case (char)0x10: rez[i]='?'; break;
			case (char)0x11: rez[i]='?'; break;
			case (char)0x12: rez[i]='?'; break;
			case (char)0x13: rez[i]='?'; break;
			case (char)0x14: rez[i]='?'; break;
			case (char)0x15: rez[i]='?'; break;
			case (char)0x16: rez[i]='?'; break;
			case (char)0x17: rez[i]='?'; break;
			case (char)0x18: rez[i]='?'; break;
			case (char)0x19: rez[i]='?'; break;
			case (char)0x1a: rez[i]='?'; break;
			case (char)0x1b: rez[i]='?'; break;
			case (char)0x1c: rez[i]='?'; break;
			case (char)0x1d: rez[i]='?'; break;
			case (char)0x1e: rez[i]='?'; break;
			case (char)0x1f: rez[i]='?'; break;

			case (char)0x20: rez[i]=' '; break;
			case (char)0x21: rez[i]='!'; break;
			case (char)0x22: rez[i]='"'; break;
			case (char)0x23: rez[i]='#'; break;
			case (char)0x24: rez[i]='$'; break;
			case (char)0x25: rez[i]='%'; break;
			case (char)0x26: rez[i]='&'; break;
			case (char)0x27: rez[i]='\''; break;
			case (char)0x28: rez[i]='('; break;
			case (char)0x29: rez[i]=')'; break;
			case (char)0x2a: rez[i]='*'; break;
			case (char)0x2b: rez[i]='+'; break;
			case (char)0x2c: rez[i]=','; break;
			case (char)0x2d: rez[i]='-'; break;
			case (char)0x2e: rez[i]='.'; break;
			case (char)0x2f: rez[i]='/'; break;

			case (char)0x30: rez[i]='0'; break;
			case (char)0x31: rez[i]='1'; break;
			case (char)0x32: rez[i]='2'; break;
			case (char)0x33: rez[i]='3'; break;
			case (char)0x34: rez[i]='4'; break;
			case (char)0x35: rez[i]='5'; break;
			case (char)0x36: rez[i]='6'; break;
			case (char)0x37: rez[i]='7'; break;
			case (char)0x38: rez[i]='8'; break;
			case (char)0x39: rez[i]='9'; break;
			case (char)0x3a: rez[i]=':'; break;
			case (char)0x3b: rez[i]=';'; break;
			case (char)0x3c: rez[i]='<'; break;
			case (char)0x3d: rez[i]='='; break;
			case (char)0x3e: rez[i]='>'; break;
			case (char)0x3f: rez[i]='?'; break;

			case (char)0x40: rez[i]='@'; break;
			case (char)0x41: rez[i]='A'; break;
			case (char)0x42: rez[i]='B'; break;
			case (char)0x43: rez[i]='C'; break;
			case (char)0x44: rez[i]='D'; break;
			case (char)0x45: rez[i]='E'; break;
			case (char)0x46: rez[i]='F'; break;
			case (char)0x47: rez[i]='G'; break;
			case (char)0x48: rez[i]='H'; break;
			case (char)0x49: rez[i]='I'; break;
			case (char)0x4a: rez[i]='J'; break;
			case (char)0x4b: rez[i]='K'; break;
			case (char)0x4c: rez[i]='L'; break;
			case (char)0x4d: rez[i]='M'; break;
			case (char)0x4e: rez[i]='N'; break;
			case (char)0x4f: rez[i]='O'; break;

			case (char)0x50: rez[i]='P'; break;
			case (char)0x51: rez[i]='Q'; break;
			case (char)0x52: rez[i]='R'; break;
			case (char)0x53: rez[i]='S'; break;
			case (char)0x54: rez[i]='T'; break;
			case (char)0x55: rez[i]='U'; break;
			case (char)0x56: rez[i]='V'; break;
			case (char)0x57: rez[i]='W'; break;
			case (char)0x58: rez[i]='X'; break;
			case (char)0x59: rez[i]='Y'; break;
			case (char)0x5a: rez[i]='Z'; break;
			case (char)0x5b: rez[i]='['; break;
			case (char)0x5c: rez[i]='\\'; break;
			case (char)0x5d: rez[i]=']'; break;
			case (char)0x5e: rez[i]='^'; break;
			case (char)0x5f: rez[i]='_'; break;

			case (char)0x60: rez[i]='`'; break;
			case (char)0x61: rez[i]='a'; break;
			case (char)0x62: rez[i]='b'; break;
			case (char)0x63: rez[i]='c'; break;
			case (char)0x64: rez[i]='d'; break;
			case (char)0x65: rez[i]='e'; break;
			case (char)0x66: rez[i]='f'; break;
			case (char)0x67: rez[i]='g'; break;
			case (char)0x68: rez[i]='h'; break;
			case (char)0x69: rez[i]='i'; break;
			case (char)0x6a: rez[i]='j'; break;
			case (char)0x6b: rez[i]='k'; break;
			case (char)0x6c: rez[i]='l'; break;
			case (char)0x6d: rez[i]='m'; break;
			case (char)0x6e: rez[i]='n'; break;
			case (char)0x6f: rez[i]='o'; break;

			case (char)0x70: rez[i]='p'; break;
			case (char)0x71: rez[i]='q'; break;
			case (char)0x72: rez[i]='r'; break;
			case (char)0x73: rez[i]='s'; break;
			case (char)0x74: rez[i]='t'; break;
			case (char)0x75: rez[i]='u'; break;
			case (char)0x76: rez[i]='v'; break;
			case (char)0x77: rez[i]='w'; break;
			case (char)0x78: rez[i]='x'; break;
			case (char)0x79: rez[i]='y'; break;
			case (char)0x7a: rez[i]='z'; break;
			case (char)0x7b: rez[i]='{'; break;
			case (char)0x7c: rez[i]='|'; break;
			case (char)0x7d: rez[i]='}'; break;
			case (char)0x7e: rez[i]='~'; break;
			case (char)0x7f: rez[i]=(char)0xf5; break; //х

			case (char)0x80: rez[i]= (char)0xc0; break; //А
			case (char)0x81: rez[i]= (char)0xC1; break; //Б
			case (char)0x82: rez[i]= (char)0xC2; break; //В
			case (char)0x83: rez[i]= (char)0xC3; break; //Г
			case (char)0x84: rez[i]= (char)0xC4; break; //Д
			case (char)0x85: rez[i]= (char)0xC5; break; //Е
			case (char)0x86: rez[i]= (char)0xC6; break; //Ж
			case (char)0x87: rez[i]= (char)0xC7; break; //З
			case (char)0x88: rez[i]= (char)0xC8; break; //И
			case (char)0x89: rez[i]= (char)0xC9; break; //Й
			case (char)0x8a: rez[i]= (char)0xCA; break; //К
			case (char)0x8b: rez[i]= (char)0xCB; break; //Л
			case (char)0x8c: rez[i]= (char)0xCC; break; //М
			case (char)0x8D: rez[i]= (char)0xCD; break; //Н
			case (char)0x8E: rez[i]= (char)0xCE; break; //О
			case (char)0x8f: rez[i]= (char)0xCF; break; //П

			case (char)0x90: rez[i]= (char)0xD0; break; //Р
			case (char)0x91: rez[i]= (char)0xD1; break; //С
			case (char)0x92: rez[i]= (char)0xD2; break; //Т
			case (char)0x93: rez[i]= (char)0xD3; break; //У
			case (char)0x94: rez[i]= (char)0xD4; break; //Ф
			case (char)0x95: rez[i]= (char)0xD5; break; //Х
			case (char)0x96: rez[i]= (char)0xD6; break; //Ц
			case (char)0x97: rez[i]= (char)0xD7; break; //Ч
			case (char)0x98: rez[i]= (char)0xD8; break; //Ш
			case (char)0x99: rez[i]= (char)0xD9; break; //Щ
			case (char)0x9a: rez[i]= (char)0xDA; break; //Ъ
			case (char)0x9b: rez[i]= (char)0xDB; break; //Ы
			case (char)0x9c: rez[i]= (char)0xDC; break; //Ь
			case (char)0x9D: rez[i]= (char)0xDD; break; //Э
			case (char)0x9E: rez[i]= (char)0xDE; break; //Ю
			case (char)0x9f: rez[i]= (char)0xDF; break; //Я

			case (char)0xa0: rez[i]= (char)0xE0; break; //а
			case (char)0xA1: rez[i]= (char)0xE1; break; //б
			case (char)0xA2: rez[i]= (char)0xE2; break; //в
			case (char)0xA3: rez[i]= (char)0xE3; break; //г
			case (char)0xa4: rez[i]= (char)0xE4; break; //д
			case (char)0xA5: rez[i]= (char)0xE5; break; //е
			case (char)0xa6: rez[i]= (char)0xE6; break; //
			case (char)0xa7: rez[i]= (char)0xE7; break; //з
			case (char)0xa8: rez[i]= (char)0xE8; break; //и
			case (char)0xa9: rez[i]= (char)0xE9; break; //й
			case (char)0xAA: rez[i]= (char)0xEA; break; //к
			case (char)0xab: rez[i]= (char)0xEB; break; //л
			case (char)0xac: rez[i]= (char)0xEC; break; //м
			case (char)0xad: rez[i]= (char)0xED; break; //н
			case (char)0xae: rez[i]= (char)0xEE; break; //о
			case (char)0xAF: rez[i]= (char)0xEF; break; //п

			case (char)0xb0: rez[i]=' '; break;
			case (char)0xb1: rez[i]=' '; break;
			case (char)0xb2: rez[i]=' '; break;
			case (char)0xb3: rez[i]=' '; break;
			case (char)0xB4: rez[i]=' '; break;
			case (char)0xb5: rez[i]=' '; break;
			case (char)0xb6: rez[i]=' '; break;
			case (char)0xb7: rez[i]=' '; break;
			case (char)0xb8: rez[i]=' '; break;
			case (char)0xb9: rez[i]=' '; break;
			case (char)0xBA: rez[i]=' '; break;
			case (char)0xbb: rez[i]=' '; break;
			case (char)0xBC: rez[i]=' '; break;
			case (char)0xBD: rez[i]=' '; break;
			case (char)0xBE: rez[i]=' '; break;
			case (char)0xBF: rez[i]=' '; break;

			case (char)0xc0: rez[i]=' '; break;
			case (char)0xc1: rez[i]=' '; break;
			case (char)0xc2: rez[i]=' '; break;
			case (char)0xc3: rez[i]=' '; break;
			case (char)0xc4: rez[i]=' '; break;
			case (char)0xc5: rez[i]=' '; break;
			case (char)0xc6: rez[i]=' '; break;
			case (char)0xc7: rez[i]=' '; break;
			case (char)0xc8: rez[i]=' '; break;
			case (char)0xc9: rez[i]=' '; break;
			case (char)0xca: rez[i]=' '; break;
			case (char)0xcb: rez[i]=' '; break;
			case (char)0xcc: rez[i]=' '; break;
			case (char)0xcd: rez[i]=' '; break;
			case (char)0xce: rez[i]=' '; break;
			case (char)0xcf: rez[i]=' '; break;

			case (char)0xd0: rez[i]=' '; break;
			case (char)0xd1: rez[i]=' '; break;
			case (char)0xd2: rez[i]=' '; break;
			case (char)0xd3: rez[i]=' '; break;
			case (char)0xd4: rez[i]=' '; break;
			case (char)0xd5: rez[i]=' '; break;
			case (char)0xd6: rez[i]=' '; break;
			case (char)0xd7: rez[i]=' '; break;
			case (char)0xd8: rez[i]=' '; break;
			case (char)0xd9: rez[i]=' '; break;
			case (char)0xda: rez[i]=' '; break;
			case (char)0xdb: rez[i]=' '; break;
			case (char)0xdc: rez[i]=' '; break;
			case (char)0xdd: rez[i]=' '; break;
			case (char)0xde: rez[i]=' '; break;
			case (char)0xdf: rez[i]=' '; break;

			case (char)0xe0: rez[i]= (char)0xF0; break; //р
			case (char)0xe1: rez[i]= (char)0xF1; break; //с
			case (char)0xe2: rez[i]= (char)0xF2; break; //т
			case (char)0xe3: rez[i]= (char)0xF3; break; //у
			case (char)0xe4: rez[i]= (char)0xF4; break; //ф
			case (char)0xe5: rez[i]= (char)0xF5; break; //х
			case (char)0xe6: rez[i]= (char)0xF6; break; //ц
			case (char)0xe7: rez[i]= (char)0xF7; break; //ч
			case (char)0xe8: rez[i]= (char)0xF8; break; //ш
			case (char)0xe9: rez[i]= (char)0xF9; break; //щ
			case (char)0xea: rez[i]= (char)0xFA; break; //ъ
			case (char)0xeb: rez[i]= (char)0xFB; break; //ы
			case (char)0xec: rez[i]= (char)0xFC; break; //ь
			case (char)0xed: rez[i]= (char)0xFD; break; //э
			case (char)0xee: rez[i]= (char)0xFE; break; //ю
			case (char)0xef: rez[i]= (char)0xFF; break; //я

			case (char)0xf0: rez[i]=' '; break;
			case (char)0xf1: rez[i]=' '; break;
			case (char)0xf2: rez[i]=' '; break;
			case (char)0xf3: rez[i]=' '; break;
			case (char)0xf4: rez[i]=' '; break;
			case (char)0xf5: rez[i]=' '; break;
			case (char)0xf6: rez[i]=' '; break;
			case (char)0xf7: rez[i]=' '; break;
			case (char)0xf8: rez[i]=' '; break;
			case (char)0xf9: rez[i]=' '; break;
			case (char)0xfa: rez[i]=' '; break;
			case (char)0xfb: rez[i]=' '; break;
			case (char)0xfc: rez[i]=' '; break;
			case (char)0xfd: rez[i]=' '; break;
			case (char)0xfe: rez[i]=' '; break;
			case (char)0xff: rez[i]=' '; break;
			default:
				rez[i]=L'?';
		}
	}
	return rez;
}

std::string fromASCIItoDOS(const std::string str)
{
	std::string rez(str.length(), '\0');
	for(size_t i=0;i<str.length();i++)
	{
		switch ((char)str[i])
		{
			case (char)0x00: rez[i]=(char)0x00; break;
			case (char)0x01: rez[i]=(char)0x01; break;
			case (char)0x02: rez[i]='?'; break;
			case (char)0x03: rez[i]='?'; break;
			case (char)0x04: rez[i]='?'; break;
			case (char)0x05: rez[i]='?'; break;
			case (char)0x06: rez[i]='?'; break;
			case (char)0x07: rez[i]='?'; break;
			case (char)0x08: rez[i]='?'; break;
			case (char)0x09: rez[i]='?'; break;
			case (char)0x0a: rez[i]='?'; break;
			case (char)0x0b: rez[i]='?'; break;
			case (char)0x0c: rez[i]='?'; break;
			case (char)0x0d: rez[i]='?'; break;
			case (char)0x0e: rez[i]='?'; break;
			case (char)0x0f: rez[i]='?'; break;

			case (char)0x10: rez[i]='?'; break;
			case (char)0x11: rez[i]='?'; break;
			case (char)0x12: rez[i]='?'; break;
			case (char)0x13: rez[i]='?'; break;
			case (char)0x14: rez[i]='?'; break;
			case (char)0x15: rez[i]='?'; break;
			case (char)0x16: rez[i]='?'; break;
			case (char)0x17: rez[i]='?'; break;
			case (char)0x18: rez[i]='?'; break;
			case (char)0x19: rez[i]='?'; break;
			case (char)0x1a: rez[i]='?'; break;
			case (char)0x1b: rez[i]='?'; break;
			case (char)0x1c: rez[i]='?'; break;
			case (char)0x1d: rez[i]='?'; break;
			case (char)0x1e: rez[i]='?'; break;
			case (char)0x1f: rez[i]='?'; break;

			case (char)0x20: rez[i]=' '; break;
			case (char)0x21: rez[i]='!'; break;
			case (char)0x22: rez[i]='"'; break;
			case (char)0x23: rez[i]='#'; break;
			case (char)0x24: rez[i]='$'; break;
			case (char)0x25: rez[i]='%'; break;
			case (char)0x26: rez[i]='&'; break;
			case (char)0x27: rez[i]='\''; break;
			case (char)0x28: rez[i]='('; break;
			case (char)0x29: rez[i]=')'; break;
			case (char)0x2a: rez[i]='*'; break;
			case (char)0x2b: rez[i]='+'; break;
			case (char)0x2c: rez[i]=','; break;
			case (char)0x2d: rez[i]='-'; break;
			case (char)0x2e: rez[i]='.'; break;
			case (char)0x2f: rez[i]='/'; break;

			case (char)0x30: rez[i]='0'; break;
			case (char)0x31: rez[i]='1'; break;
			case (char)0x32: rez[i]='2'; break;
			case (char)0x33: rez[i]='3'; break;
			case (char)0x34: rez[i]='4'; break;
			case (char)0x35: rez[i]='5'; break;
			case (char)0x36: rez[i]='6'; break;
			case (char)0x37: rez[i]='7'; break;
			case (char)0x38: rez[i]='8'; break;
			case (char)0x39: rez[i]='9'; break;
			case (char)0x3a: rez[i]=':'; break;
			case (char)0x3b: rez[i]=';'; break;
			case (char)0x3c: rez[i]='<'; break;
			case (char)0x3d: rez[i]='='; break;
			case (char)0x3e: rez[i]='>'; break;
			case (char)0x3f: rez[i]='?'; break;

			case (char)0x40: rez[i]='@'; break;
			case (char)0x41: rez[i]='A'; break;
			case (char)0x42: rez[i]='B'; break;
			case (char)0x43: rez[i]='C'; break;
			case (char)0x44: rez[i]='D'; break;
			case (char)0x45: rez[i]='E'; break;
			case (char)0x46: rez[i]='F'; break;
			case (char)0x47: rez[i]='G'; break;
			case (char)0x48: rez[i]='H'; break;
			case (char)0x49: rez[i]='I'; break;
			case (char)0x4a: rez[i]='J'; break;
			case (char)0x4b: rez[i]='K'; break;
			case (char)0x4c: rez[i]='L'; break;
			case (char)0x4d: rez[i]='M'; break;
			case (char)0x4e: rez[i]='N'; break;
			case (char)0x4f: rez[i]='O'; break;

			case (char)0x50: rez[i]='P'; break;
			case (char)0x51: rez[i]='Q'; break;
			case (char)0x52: rez[i]='R'; break;
			case (char)0x53: rez[i]='S'; break;
			case (char)0x54: rez[i]='T'; break;
			case (char)0x55: rez[i]='U'; break;
			case (char)0x56: rez[i]='V'; break;
			case (char)0x57: rez[i]='W'; break;
			case (char)0x58: rez[i]='X'; break;
			case (char)0x59: rez[i]='Y'; break;
			case (char)0x5a: rez[i]='Z'; break;
			case (char)0x5b: rez[i]='['; break;
			case (char)0x5c: rez[i]='\\'; break;
			case (char)0x5d: rez[i]=']'; break;
			case (char)0x5e: rez[i]='^'; break;
			case (char)0x5f: rez[i]='_'; break;

			case (char)0x60: rez[i]='`'; break;
			case (char)0x61: rez[i]='a'; break;
			case (char)0x62: rez[i]='b'; break;
			case (char)0x63: rez[i]='c'; break;
			case (char)0x64: rez[i]='d'; break;
			case (char)0x65: rez[i]='e'; break;
			case (char)0x66: rez[i]='f'; break;
			case (char)0x67: rez[i]='g'; break;
			case (char)0x68: rez[i]='h'; break;
			case (char)0x69: rez[i]='i'; break;
			case (char)0x6a: rez[i]='j'; break;
			case (char)0x6b: rez[i]='k'; break;
			case (char)0x6c: rez[i]='l'; break;
			case (char)0x6d: rez[i]='m'; break;
			case (char)0x6e: rez[i]='n'; break;
			case (char)0x6f: rez[i]='o'; break;

			case (char)0x70: rez[i]='p'; break;
			case (char)0x71: rez[i]='q'; break;
			case (char)0x72: rez[i]='r'; break;
			case (char)0x73: rez[i]='s'; break;
			case (char)0x74: rez[i]='t'; break;
			case (char)0x75: rez[i]='u'; break;
			case (char)0x76: rez[i]='v'; break;
			case (char)0x77: rez[i]='w'; break;
			case (char)0x78: rez[i]='x'; break;
			case (char)0x79: rez[i]='y'; break;
			case (char)0x7a: rez[i]='z'; break;
			case (char)0x7b: rez[i]='{'; break;
			case (char)0x7c: rez[i]='|'; break;
			case (char)0x7d: rez[i]='}'; break;
			case (char)0x7e: rez[i]='~'; break;
			case (char)0x7f: rez[i]=' '; break; //127

			case (char)0x80: rez[i]=' '; break; //128
			case (char)0x81: rez[i]=' '; break;
			case (char)0x82: rez[i]=' '; break;
			case (char)0x83: rez[i]=' '; break;
			case (char)0x84: rez[i]=' '; break;
			case (char)0x85: rez[i]=' '; break;
			case (char)0x86: rez[i]=' '; break;
			case (char)0x87: rez[i]=' '; break;
			case (char)0x88: rez[i]=' '; break;
			case (char)0x89: rez[i]=' '; break;
			case (char)0x8a: rez[i]=' '; break;
			case (char)0x8b: rez[i]=' '; break;
			case (char)0x8c: rez[i]=' '; break;
			case (char)0x8D: rez[i]=' '; break;
			case (char)0x8E: rez[i]=' '; break;
			case (char)0x8f: rez[i]=' '; break;

			case (char)0x90: rez[i]=' '; break;
			case (char)0x91: rez[i]=' '; break;
			case (char)0x92: rez[i]=' '; break;
			case (char)0x93: rez[i]=' '; break;
			case (char)0x94: rez[i]=' '; break;
			case (char)0x95: rez[i]=' '; break;
			case (char)0x96: rez[i]=' '; break;
			case (char)0x97: rez[i]=' '; break;
			case (char)0x98: rez[i]=' '; break;
			case (char)0x99: rez[i]=' '; break;
			case (char)0x9a: rez[i]=' '; break;
			case (char)0x9b: rez[i]=' '; break;
			case (char)0x9c: rez[i]=' '; break;
			case (char)0x9D: rez[i]=' '; break;
			case (char)0x9E: rez[i]=' '; break;
			case (char)0x9f: rez[i]=' '; break;

			case (char)0xa0: rez[i]=' '; break;
			case (char)0xA1: rez[i]=' '; break;
			case (char)0xA2: rez[i]=' '; break;
			case (char)0xA3: rez[i]=' '; break;
			case (char)0xa4: rez[i]=' '; break;
			case (char)0xA5: rez[i]=' '; break;
			case (char)0xa6: rez[i]=' '; break;
			case (char)0xa7: rez[i]=' '; break;
			case (char)0xa8: rez[i]=' '; break;
			case (char)0xa9: rez[i]=' '; break;
			case (char)0xAA: rez[i]=' '; break;
			case (char)0xab: rez[i]=' '; break;
			case (char)0xac: rez[i]=' '; break;
			case (char)0xad: rez[i]=' '; break;
			case (char)0xae: rez[i]=' '; break;
			case (char)0xAF: rez[i]=' '; break;

			case (char)0xb0: rez[i]=' '; break;
			case (char)0xb1: rez[i]=' '; break;
			case (char)0xb2: rez[i]=' '; break;
			case (char)0xb3: rez[i]=' '; break;
			case (char)0xB4: rez[i]=' '; break;
			case (char)0xb5: rez[i]=' '; break;
			case (char)0xb6: rez[i]=' '; break;
			case (char)0xb7: rez[i]=' '; break;
			case (char)0xb8: rez[i]=' '; break;
			case (char)0xb9: rez[i]=' '; break;
			case (char)0xBA: rez[i]=' '; break;
			case (char)0xbb: rez[i]=' '; break;
			case (char)0xBC: rez[i]=' '; break;
			case (char)0xBD: rez[i]=' '; break;
			case (char)0xBE: rez[i]=' '; break;
			case (char)0xBF: rez[i]=' '; break;

			case (char)0xc0: rez[i]=(char)0x80; break;
			case (char)0xc1: rez[i]=(char)0x81; break;
			case (char)0xc2: rez[i]=(char)0x82; break;
			case (char)0xc3: rez[i]=(char)0x83; break;
			case (char)0xc4: rez[i]=(char)0x84; break;
			case (char)0xc5: rez[i]=(char)0x85; break;
			case (char)0xc6: rez[i]=(char)0x86; break;
			case (char)0xc7: rez[i]=(char)0x87; break;
			case (char)0xc8: rez[i]=(char)0x88; break;
			case (char)0xc9: rez[i]=(char)0x89; break;
			case (char)0xca: rez[i]=(char)0x8a; break;
			case (char)0xcb: rez[i]=(char)0x8b; break;
			case (char)0xcc: rez[i]=(char)0x8c; break;
			case (char)0xcd: rez[i]=(char)0x8d; break;
			case (char)0xce: rez[i]=(char)0x8e; break;
			case (char)0xcf: rez[i]=(char)0x8f; break;

			case (char)0xd0: rez[i]=(char)0x90; break;
			case (char)0xd1: rez[i]=(char)0x91; break;
			case (char)0xd2: rez[i]=(char)0x92; break;
			case (char)0xd3: rez[i]=(char)0x93; break;
			case (char)0xd4: rez[i]=(char)0x94; break;
			case (char)0xd5: rez[i]=(char)0x95; break;
			case (char)0xd6: rez[i]=(char)0x96; break;
			case (char)0xd7: rez[i]=(char)0x97; break;
			case (char)0xd8: rez[i]=(char)0x98; break;
			case (char)0xd9: rez[i]=(char)0x99; break;
			case (char)0xda: rez[i]=(char)0x9a; break;
			case (char)0xdb: rez[i]=(char)0x9b; break;
			case (char)0xdc: rez[i]=(char)0x9c; break;
			case (char)0xdd: rez[i]=(char)0x9d; break;
			case (char)0xde: rez[i]=(char)0x9e; break;
			case (char)0xdf: rez[i]=(char)0x9f; break;

			case (char)0xe0: rez[i]=(char)0xa0; break;
			case (char)0xe1: rez[i]=(char)0xa1; break;
			case (char)0xe2: rez[i]=(char)0xa2; break;
			case (char)0xe3: rez[i]=(char)0xa3; break;
			case (char)0xe4: rez[i]=(char)0xa4; break;
			case (char)0xe5: rez[i]=(char)0xa5; break;
			case (char)0xe6: rez[i]=(char)0xa6; break;
			case (char)0xe7: rez[i]=(char)0xa7; break;
			case (char)0xe8: rez[i]=(char)0xa8; break;
			case (char)0xe9: rez[i]=(char)0xa9; break;
			case (char)0xea: rez[i]=(char)0xaa; break;
			case (char)0xeb: rez[i]=(char)0xab; break;
			case (char)0xec: rez[i]=(char)0xac; break;
			case (char)0xed: rez[i]=(char)0xad; break;
			case (char)0xee: rez[i]=(char)0xae; break;
			case (char)0xef: rez[i]=(char)0xaf; break;

			case (char)0xf0: rez[i]=(char)0xe0; break;
			case (char)0xf1: rez[i]=(char)0xe1; break;
			case (char)0xf2: rez[i]=(char)0xe2; break;
			case (char)0xf3: rez[i]=(char)0xe3; break;
			case (char)0xf4: rez[i]=(char)0xe4; break;
			case (char)0xf5: rez[i]=(char)0xe5; break;
			case (char)0xf6: rez[i]=(char)0xe6; break;
			case (char)0xf7: rez[i]=(char)0xe7; break;
			case (char)0xf8: rez[i]=(char)0xe8; break;
			case (char)0xf9: rez[i]=(char)0xe9; break;
			case (char)0xfa: rez[i]=(char)0xea; break;
			case (char)0xfb: rez[i]=(char)0xeb; break;
			case (char)0xfc: rez[i]=(char)0xec; break;
			case (char)0xfd: rez[i]=(char)0xed; break;
			case (char)0xfe: rez[i]=(char)0xee; break;
			case (char)0xff: rez[i]=(char)0xef; break;
			default:
				rez[i]=L'?';
		}
	}
	return rez;
}

//Из казахского ASCII в юникод см: http://foxtools.ru/ASCII#1251
std::wstring fromKAZASCII(const std::string str)
{
	std::wstring rez(str.length(), '\0');
	for(size_t i=0;i<str.length();i++)
	{
		switch ((char)str[i])
		{
			case (char)0x00: rez[i]=0x00; break;
			case (char)0x01: rez[i]=0x01; break;
			case (char)0x02: rez[i]=L'?'; break;
			case (char)0x03: rez[i]=L'?'; break;
			case (char)0x04: rez[i]=L'?'; break;
			case (char)0x05: rez[i]=L'?'; break;
			case (char)0x06: rez[i]=L'?'; break;
			case (char)0x07: rez[i]=L'?'; break;
			case (char)0x08: rez[i]=L'?'; break;
			case (char)0x09: rez[i]=L'?'; break;
			case (char)0x0a: rez[i]=L'?'; break;
			case (char)0x0b: rez[i]=L'?'; break;
			case (char)0x0c: rez[i]=L'?'; break;
			case (char)0x0d: rez[i]=L'?'; break;
			case (char)0x0e: rez[i]=L'?'; break;
			case (char)0x0f: rez[i]=L'?'; break;

			case (char)0x10: rez[i]=L'?'; break;
			case (char)0x11: rez[i]=L'?'; break;
			case (char)0x12: rez[i]=L'?'; break;
			case (char)0x13: rez[i]=L'?'; break;
			case (char)0x14: rez[i]=L'?'; break;
			case (char)0x15: rez[i]=L'?'; break;
			case (char)0x16: rez[i]=L'?'; break;
			case (char)0x17: rez[i]=L'?'; break;
			case (char)0x18: rez[i]=L'?'; break;
			case (char)0x19: rez[i]=L'?'; break;
			case (char)0x1a: rez[i]=L'?'; break;
			case (char)0x1b: rez[i]=L'?'; break;
			case (char)0x1c: rez[i]=L'?'; break;
			case (char)0x1d: rez[i]=L'?'; break;
			case (char)0x1e: rez[i]=L'?'; break;
			case (char)0x1f: rez[i]=L'?'; break;

			case (char)0x20: rez[i]=L' '; break;
			case (char)0x21: rez[i]=L'!'; break;
			case (char)0x22: rez[i]=L'"'; break;
			case (char)0x23: rez[i]=L'#'; break;
			case (char)0x24: rez[i]=L'$'; break;
			case (char)0x25: rez[i]=L'%'; break;
			case (char)0x26: rez[i]=L'&'; break;
			case (char)0x27: rez[i]=L'\''; break;
			case (char)0x28: rez[i]=L'('; break;
			case (char)0x29: rez[i]=L')'; break;
			case (char)0x2a: rez[i]=L'*'; break;
			case (char)0x2b: rez[i]=L'+'; break;
			case (char)0x2c: rez[i]=L','; break;
			case (char)0x2d: rez[i]=L'-'; break;
			case (char)0x2e: rez[i]=L'.'; break;
			case (char)0x2f: rez[i]=L'/'; break;

			case (char)0x30: rez[i]=L'0'; break;
			case (char)0x31: rez[i]=L'1'; break;
			case (char)0x32: rez[i]=L'2'; break;
			case (char)0x33: rez[i]=L'3'; break;
			case (char)0x34: rez[i]=L'4'; break;
			case (char)0x35: rez[i]=L'5'; break;
			case (char)0x36: rez[i]=L'6'; break;
			case (char)0x37: rez[i]=L'7'; break;
			case (char)0x38: rez[i]=L'8'; break;
			case (char)0x39: rez[i]=L'9'; break;
			case (char)0x3a: rez[i]=L':'; break;
			case (char)0x3b: rez[i]=L';'; break;
			case (char)0x3c: rez[i]=L'<'; break;
			case (char)0x3d: rez[i]=L'='; break;
			case (char)0x3e: rez[i]=L'>'; break;
			case (char)0x3f: rez[i]=L'?'; break;

			case (char)0x40: rez[i]=L'@'; break;
			case (char)0x41: rez[i]=L'A'; break;
			case (char)0x42: rez[i]=L'B'; break;
			case (char)0x43: rez[i]=L'C'; break;
			case (char)0x44: rez[i]=L'D'; break;
			case (char)0x45: rez[i]=L'E'; break;
			case (char)0x46: rez[i]=L'F'; break;
			case (char)0x47: rez[i]=L'G'; break;
			case (char)0x48: rez[i]=L'H'; break;
			case (char)0x49: rez[i]=L'I'; break;
			case (char)0x4a: rez[i]=L'J'; break;
			case (char)0x4b: rez[i]=L'K'; break;
			case (char)0x4c: rez[i]=L'L'; break;
			case (char)0x4d: rez[i]=L'M'; break;
			case (char)0x4e: rez[i]=L'N'; break;
			case (char)0x4f: rez[i]=L'O'; break;

			case (char)0x50: rez[i]=L'P'; break;
			case (char)0x51: rez[i]=L'Q'; break;
			case (char)0x52: rez[i]=L'R'; break;
			case (char)0x53: rez[i]=L'S'; break;
			case (char)0x54: rez[i]=L'T'; break;
			case (char)0x55: rez[i]=L'U'; break;
			case (char)0x56: rez[i]=L'V'; break;
			case (char)0x57: rez[i]=L'W'; break;
			case (char)0x58: rez[i]=L'X'; break;
			case (char)0x59: rez[i]=L'Y'; break;
			case (char)0x5a: rez[i]=L'Z'; break;
			case (char)0x5b: rez[i]=L'['; break;
			case (char)0x5c: rez[i]=L'\\'; break;
			case (char)0x5d: rez[i]=L']'; break;
			case (char)0x5e: rez[i]=L'^'; break;
			case (char)0x5f: rez[i]=L'_'; break;

			case (char)0x60: rez[i]=L'`'; break;
			case (char)0x61: rez[i]=L'a'; break;
			case (char)0x62: rez[i]=L'b'; break;
			case (char)0x63: rez[i]=L'c'; break;
			case (char)0x64: rez[i]=L'd'; break;
			case (char)0x65: rez[i]=L'e'; break;
			case (char)0x66: rez[i]=L'f'; break;
			case (char)0x67: rez[i]=L'g'; break;
			case (char)0x68: rez[i]=L'h'; break;
			case (char)0x69: rez[i]=L'i'; break;
			case (char)0x6a: rez[i]=L'j'; break;
			case (char)0x6b: rez[i]=L'k'; break;
			case (char)0x6c: rez[i]=L'l'; break;
			case (char)0x6d: rez[i]=L'm'; break;
			case (char)0x6e: rez[i]=L'n'; break;
			case (char)0x6f: rez[i]=L'o'; break;

			case (char)0x70: rez[i]=L'p'; break;
			case (char)0x71: rez[i]=L'q'; break;
			case (char)0x72: rez[i]=L'r'; break;
			case (char)0x73: rez[i]=L's'; break;
			case (char)0x74: rez[i]=L't'; break;
			case (char)0x75: rez[i]=L'u'; break;
			case (char)0x76: rez[i]=L'v'; break;
			case (char)0x77: rez[i]=L'w'; break;
			case (char)0x78: rez[i]=L'x'; break;
			case (char)0x79: rez[i]=L'y'; break;
			case (char)0x7a: rez[i]=L'z'; break;
			case (char)0x7b: rez[i]=L'{'; break;
			case (char)0x7c: rez[i]=L'|'; break;
			case (char)0x7d: rez[i]=L'}'; break;
			case (char)0x7e: rez[i]=L'~'; break;
			case (char)0x7f: rez[i]=L'×'; break; //127

			case (char)0x80: rez[i]=L' '; break;
			case (char)0x81: rez[i]=L'Ғ'; break;
			case (char)0x82: rez[i]=L' '; break;
			case (char)0x83: rez[i]=L'ғ'; break; //+ да норм
			case (char)0x84: rez[i]=L' '; break;
			case (char)0x85: rez[i]=L' '; break;
			case (char)0x86: rez[i]=L' '; break;
			case (char)0x87: rez[i]=L' '; break;
			case (char)0x88: rez[i]=L' '; break;
			case (char)0x89: rez[i]=L' '; break;
			case (char)0x8a: rez[i]=L'Ә'; break;
			case (char)0x8b: rez[i]=L' '; break;
			case (char)0x8c: rez[i]=L'Ң'; break;
			case (char)0x8D: rez[i]=L'Қ'; break;
			case (char)0x8E: rez[i]=L'Һ'; break;
			case (char)0x8f: rez[i]=L' '; break;

			case (char)0x90: rez[i]=L' '; break;
			case (char)0x91: rez[i]=L' '; break;
			case (char)0x92: rez[i]=L' '; break;
			case (char)0x93: rez[i]=L' '; break;
			case (char)0x94: rez[i]=L' '; break;
			case (char)0x95: rez[i]=L' '; break;
			case (char)0x96: rez[i]=L' '; break;
			case (char)0x97: rez[i]=L' '; break;
			case (char)0x98: rez[i]=L' '; break;
			case (char)0x99: rez[i]=L' '; break;
			case (char)0x9a: rez[i]=L'ә'; break;
			case (char)0x9b: rez[i]=L' '; break;
			case (char)0x9c: rez[i]=L'ң'; break;
			case (char)0x9D: rez[i]=L'қ'; break;
			case (char)0x9E: rez[i]=L'һ'; break;
			case (char)0x9f: rez[i]=L' '; break;

			case (char)0xa0: rez[i]=L' '; break;
			case (char)0xA1: rez[i]=L'Ұ'; break;
			case (char)0xA2: rez[i]=L'ұ'; break;
			case (char)0xA3: rez[i]=L' '; break;
			case (char)0xa4: rez[i]=L' '; break;
			case (char)0xA5: rez[i]=L' '; break;
			case (char)0xa6: rez[i]=L' '; break;
			case (char)0xa7: rez[i]=L' '; break;
			case (char)0xa8: rez[i]=L'Ё'; break;
			case (char)0xa9: rez[i]=L' '; break;
			case (char)0xAA: rez[i]=L'Ө'; break;
			case (char)0xab: rez[i]=L' '; break;
			case (char)0xac: rez[i]=L' '; break;
			case (char)0xad: rez[i]=L' '; break;
			case (char)0xae: rez[i]=L' '; break;
			case (char)0xAF: rez[i]=L'Ү'; break;

			case (char)0xb0: rez[i]=L' '; break;
			case (char)0xb1: rez[i]=L' '; break;
			case (char)0xb2: rez[i]=L'І'; break;
			case (char)0xb3: rez[i]=L'і'; break;
			case (char)0xB4: rez[i]=L' '; break;
			case (char)0xb5: rez[i]=L' '; break;
			case (char)0xb6: rez[i]=L' '; break;
			case (char)0xb7: rez[i]=L' '; break;
			case (char)0xb8: rez[i]=L'ё'; break;
			case (char)0xb9: rez[i]=L'№'; break;
			case (char)0xBA: rez[i]=L'ө'; break;
			case (char)0xbb: rez[i]=L' '; break;
			case (char)0xBC: rez[i]=L' '; break;
			case (char)0xBD: rez[i]=L' '; break;
			case (char)0xBE: rez[i]=L' '; break;
			case (char)0xBF: rez[i]=L'ү'; break;

			case (char)0xc0: rez[i]=L'А'; break;
			case (char)0xc1: rez[i]=L'Б'; break;
			case (char)0xc2: rez[i]=L'В'; break;
			case (char)0xc3: rez[i]=L'Г'; break;
			case (char)0xc4: rez[i]=L'Д'; break;
			case (char)0xc5: rez[i]=L'Е'; break;
			case (char)0xc6: rez[i]=L'Ж'; break;
			case (char)0xc7: rez[i]=L'З'; break;
			case (char)0xc8: rez[i]=L'И'; break;
			case (char)0xc9: rez[i]=L'Й'; break;
			case (char)0xca: rez[i]=L'К'; break;
			case (char)0xcb: rez[i]=L'Л'; break;
			case (char)0xcc: rez[i]=L'М'; break;
			case (char)0xcd: rez[i]=L'Н'; break;
			case (char)0xce: rez[i]=L'О'; break;
			case (char)0xcf: rez[i]=L'П'; break;

			case (char)0xd0: rez[i]=L'Р'; break;
			case (char)0xd1: rez[i]=L'С'; break;
			case (char)0xd2: rez[i]=L'Т'; break;
			case (char)0xd3: rez[i]=L'У'; break;
			case (char)0xd4: rez[i]=L'Ф'; break;
			case (char)0xd5: rez[i]=L'Х'; break;
			case (char)0xd6: rez[i]=L'Ц'; break;
			case (char)0xd7: rez[i]=L'Ч'; break;
			case (char)0xd8: rez[i]=L'Ш'; break;
			case (char)0xd9: rez[i]=L'Щ'; break;
			case (char)0xda: rez[i]=L'Ъ'; break;
			case (char)0xdb: rez[i]=L'Ы'; break;
			case (char)0xdc: rez[i]=L'Ь'; break;
			case (char)0xdd: rez[i]=L'Э'; break;
			case (char)0xde: rez[i]=L'Ю'; break;
			case (char)0xdf: rez[i]=L'Я'; break;

			case (char)0xe0: rez[i]=L'а'; break;
			case (char)0xe1: rez[i]=L'б'; break;
			case (char)0xe2: rez[i]=L'в'; break;
			case (char)0xe3: rez[i]=L'г'; break;
			case (char)0xe4: rez[i]=L'д'; break;
			case (char)0xe5: rez[i]=L'е'; break;
			case (char)0xe6: rez[i]=L'ж'; break;
			case (char)0xe7: rez[i]=L'з'; break;
			case (char)0xe8: rez[i]=L'и'; break;
			case (char)0xe9: rez[i]=L'й'; break;
			case (char)0xea: rez[i]=L'к'; break;
			case (char)0xeb: rez[i]=L'л'; break;
			case (char)0xec: rez[i]=L'м'; break;
			case (char)0xed: rez[i]=L'н'; break;
			case (char)0xee: rez[i]=L'о'; break;
			case (char)0xef: rez[i]=L'п'; break;

			case (char)0xf0: rez[i]=L'р'; break;
			case (char)0xf1: rez[i]=L'с'; break;
			case (char)0xf2: rez[i]=L'т'; break;
			case (char)0xf3: rez[i]=L'у'; break;
			case (char)0xf4: rez[i]=L'ф'; break;
			case (char)0xf5: rez[i]=L'х'; break;
			case (char)0xf6: rez[i]=L'ц'; break;
			case (char)0xf7: rez[i]=L'ч'; break;
			case (char)0xf8: rez[i]=L'ш'; break;
			case (char)0xf9: rez[i]=L'щ'; break;
			case (char)0xfa: rez[i]=L'ъ'; break;
			case (char)0xfb: rez[i]=L'ы'; break;
			case (char)0xfc: rez[i]=L'ь'; break;
			case (char)0xfd: rez[i]=L'э'; break;
			case (char)0xfe: rez[i]=L'ю'; break;
			case (char)0xff: rez[i]=L'я'; break;
			default:
				rez[i]=L'?';
		}
	}
	return rez;
}

std::string toKAZASCII(const std::wstring str)
{
	std::string rez(str.length(), '\0');
	for(size_t i=0;i<str.length();i++)
	{
		switch (str[i])
		{
			case 0x00: rez[i]=(char)0x00; break;
			case 0x01: rez[i]=(char)0x01; break;
			case 0x02: rez[i]=(char)0x02; break;
			case 0x03: rez[i]=(char)0x03; break;
			case 0x04: rez[i]=(char)0x04; break;
			case 0x05: rez[i]=(char)0x05; break;
			case 0x06: rez[i]=(char)0x06; break;
			case 0x07: rez[i]=(char)0x07; break;
			case 0x08: rez[i]=(char)0x08; break;
			case 0x09: rez[i]=(char)0x09; break;
			case 0x0a: rez[i]=(char)0x0a; break;
			case 0x0b: rez[i]=(char)0x0b; break;
			case 0x0c: rez[i]=(char)0x0c; break;
			case 0x0d: rez[i]=(char)0x0d; break;
			case 0x0e: rez[i]=(char)0x0e; break;
			case 0x0f: rez[i]=(char)0x0f; break;

			case 0x10: rez[i]=(char)0x10; break;
			case 0x11: rez[i]=(char)0x11; break;
			case 0x12: rez[i]=(char)0x12; break;
			case 0x13: rez[i]=(char)0x13; break;
			case 0x14: rez[i]=(char)0x14; break;
			case 0x15: rez[i]=(char)0x15; break;
			case 0x16: rez[i]=(char)0x16; break;
			case 0x17: rez[i]=(char)0x17; break;
			case 0x18: rez[i]=(char)0x18; break;
			case 0x19: rez[i]=(char)0x19; break;
			case 0x1a: rez[i]=(char)0x1a; break;
			case 0x1b: rez[i]=(char)0x1b; break;
			case 0x1c: rez[i]=(char)0x1c; break;
			case 0x1d: rez[i]=(char)0x1d; break;
			case 0x1e: rez[i]=(char)0x1e; break;
			case 0x1f: rez[i]=(char)0x1f; break;

			case L' ': rez[i]=(char)0x20; break;
			case L'!': rez[i]=(char)0x21; break;
			case L'"': rez[i]=(char)0x22; break;
			case L'#': rez[i]=(char)0x23; break;
			case L'$': rez[i]=(char)0x24; break;
			case L'%': rez[i]=(char)0x25; break;
			case L'&': rez[i]=(char)0x26; break;
			case L'\'': rez[i]=(char)0x27; break;
			case L'(': rez[i]=(char)0x28; break;
			case L')': rez[i]=(char)0x29; break;
			case L'*': rez[i]=(char)0x2a; break;
			case L'+': rez[i]=(char)0x2b; break;
			case L',': rez[i]=(char)0x2c; break;
			case L'-': rez[i]=(char)0x2d; break;
			case L'.': rez[i]=(char)0x2e; break;
			case L'/': rez[i]=(char)0x2f; break;

			case L'0': rez[i]=(char)0x30; break;
			case L'1': rez[i]=(char)0x31; break;
			case L'2': rez[i]=(char)0x32; break;
			case L'3': rez[i]=(char)0x33; break;
			case L'4': rez[i]=(char)0x34; break;
			case L'5': rez[i]=(char)0x35; break;
			case L'6': rez[i]=(char)0x36; break;
			case L'7': rez[i]=(char)0x37; break;
			case L'8': rez[i]=(char)0x38; break;
			case L'9': rez[i]=(char)0x39; break;
			case L':': rez[i]=(char)0x3a; break;
			case L';': rez[i]=(char)0x3b; break;
			case L'<': rez[i]=(char)0x3c; break;
			case L'=': rez[i]=(char)0x3d; break;
			case L'>': rez[i]=(char)0x3e; break;
			case L'?': rez[i]=(char)0x3f; break;

			case L'@': rez[i]=(char)0x40; break;
			case L'A': rez[i]=(char)0x41; break;
			case L'B': rez[i]=(char)0x42; break;
			case L'C': rez[i]=(char)0x43; break;
			case L'D': rez[i]=(char)0x44; break;
			case L'E': rez[i]=(char)0x45; break;
			case L'F': rez[i]=(char)0x46; break;
			case L'G': rez[i]=(char)0x47; break;
			case L'H': rez[i]=(char)0x48; break;
			case L'I': rez[i]=(char)0x49; break;
			case L'J': rez[i]=(char)0x4a; break;
			case L'K': rez[i]=(char)0x4b; break;
			case L'L': rez[i]=(char)0x4c; break;
			case L'M': rez[i]=(char)0x4d; break;
			case L'N': rez[i]=(char)0x4e; break;
			case L'O': rez[i]=(char)0x4f; break;

			case L'P': rez[i]=(char)0x50; break;
			case L'Q': rez[i]=(char)0x51; break;
			case L'R': rez[i]=(char)0x52; break;
			case L'S': rez[i]=(char)0x53; break;
			case L'T': rez[i]=(char)0x54; break;
			case L'U': rez[i]=(char)0x55; break;
			case L'V': rez[i]=(char)0x56; break;
			case L'W': rez[i]=(char)0x57; break;
			case L'X': rez[i]=(char)0x58; break;
			case L'Y': rez[i]=(char)0x59; break;
			case L'Z': rez[i]=(char)0x5a; break;
			case L'[': rez[i]=(char)0x5b; break;
			case L'\\': rez[i]=(char)0x5c; break;
			case L']': rez[i]=(char)0x5d; break;
			case L'^': rez[i]=(char)0x5e; break;
			case L'_': rez[i]=(char)0x5f; break;

			case L'`': rez[i]=(char)0x60; break;
			case L'a': rez[i]=(char)0x61; break;
			case L'b': rez[i]=(char)0x62; break;
			case L'c': rez[i]=(char)0x63; break;
			case L'd': rez[i]=(char)0x64; break;
			case L'e': rez[i]=(char)0x65; break;
			case L'f': rez[i]=(char)0x66; break;
			case L'g': rez[i]=(char)0x67; break;
			case L'h': rez[i]=(char)0x68; break;
			case L'i': rez[i]=(char)0x69; break;
			case L'j': rez[i]=(char)0x6a; break;
			case L'k': rez[i]=(char)0x6b; break;
			case L'l': rez[i]=(char)0x6c; break;
			case L'm': rez[i]=(char)0x6d; break;
			case L'n': rez[i]=(char)0x6e; break;
			case L'o': rez[i]=(char)0x6f; break;

			case L'p': rez[i]=(char)0x70; break;
			case L'q': rez[i]=(char)0x71; break;
			case L'r': rez[i]=(char)0x72; break;
			case L's': rez[i]=(char)0x73; break;
			case L't': rez[i]=(char)0x74; break;
			case L'u': rez[i]=(char)0x75; break;
			case L'v': rez[i]=(char)0x76; break;
			case L'w': rez[i]=(char)0x77; break;
			case L'x': rez[i]=(char)0x78; break;
			case L'y': rez[i]=(char)0x79; break;
			case L'z': rez[i]=(char)0x7a; break;
			case L'{': rez[i]=(char)0x7b; break;
			case L'|': rez[i]=(char)0x7c; break;
			case L'}': rez[i]=(char)0x7d; break;
			case L'~': rez[i]=(char)0x7e; break;
			case L'×': rez[i]=(char)0x7f; break; //?

			//case L' ': rez[i]=(char)0x80; break;
			case L'Ғ': rez[i]=(char)0x81; break;
			//case L' ': rez[i]=(char)0x82; break;
			case L'ғ': rez[i]=(char)0x83; break;
			//case L' ': rez[i]=(char)0x84; break;
			//case L' ': rez[i]=(char)0x85; break;
			//case L' ': rez[i]=(char)0x86; break;
			//case L' ': rez[i]=(char)0x87; break;
			//case L' ': rez[i]=(char)0x88; break;
			case L'№': rez[i]=(char)-71; break; //Не знаю почему но код 0x89 ошибочный поэтому поставил -71
			case L'Ә': rez[i]=(char)0x8a; break;
			//case L' ': rez[i]=(char)0x8b; break;
			case L'Ң': rez[i]=(char)0x8c; break;
			case L'Қ': rez[i]=(char)0x8D; break;
			case L'Һ': rez[i]=(char)0x8E; break;
			//case L' ': rez[i]=(char)0x8f; break;

			//case L' ': rez[i]=(char)0x90; break;
			//case L' ': rez[i]=(char)0x91; break;
			//case L' ': rez[i]=(char)0x92; break;
			//case L' ': rez[i]=(char)0x93; break;
			//case L' ': rez[i]=(char)0x94; break;
			//case L' ': rez[i]=(char)0x95; break;
			//case L' ': rez[i]=(char)0x96; break;
			//case L' ': rez[i]=(char)0x97; break;
			//case L' ': rez[i]=(char)0x98; break;
			//case L' ': rez[i]=(char)0x99; break;
			case L'ә': rez[i]=(char)0x9a; break;
			//case L' ': rez[i]=(char)0x9b; break;
			case L'ң': rez[i]=(char)0x9c; break;
			case L'қ': rez[i]=(char)0x9D; break;
			case L'һ': rez[i]=(char)0x9E; break;
			//case L' ': rez[i]=(char)0x9f; break;

			//case L' ': rez[i]=(char)0xa0; break;
			case L'Ұ': rez[i]=(char)0xA1; break;
			case L'ұ': rez[i]=(char)0xA2; break;
			//case L' ': rez[i]=(char)0xA3; break;
			//case L' ': rez[i]=(char)0xa4; break;
			//case L' ': rez[i]=(char)0xA5; break;
			//case L' ': rez[i]=(char)0xa6; break;
			//case L' ': rez[i]=(char)0xa7; break;
			case L'Ё': rez[i]=(char)0xa8; break;
			//case L' ': rez[i]=(char)0xa9; break;
			case L'Ө': rez[i]=(char)0xAA; break;
			//case L' ': rez[i]=(char)0xab; break;
			//case L' ': rez[i]=(char)0xac; break;
			//case L' ': rez[i]=(char)0xad; break;
			//case L' ': rez[i]=(char)0xae; break;
			case L'Ү': rez[i]=(char)0xAF; break;

			//case L' ': rez[i]=(char)0xb0; break;
			//case L' ': rez[i]=(char)0xb1; break;
			case L'І': rez[i]=(char)0xb2; break;
			case L'і': rez[i]=(char)0xb3; break;
			//case L' ': rez[i]=(char)0xB4; break;
			//case L' ': rez[i]=(char)0xb5; break;
			//case L' ': rez[i]=(char)0xb6; break;
			//case L' ': rez[i]=(char)0xb7; break;
			case L'ё': rez[i]=(char)0xb8; break;
			//case L' ': rez[i]=(char)0xb9; break;
			case L'ө': rez[i]=(char)0xBA; break;
			//case L' ': rez[i]=(char)0xbb; break;
			//case L' ': rez[i]=(char)0xBC; break;
			//case L' ': rez[i]=(char)0xBD; break;
			//case L' ': rez[i]=(char)0xBE; break;
			case L'ү': rez[i]=(char)0xBF; break;

			case L'А': rez[i]=(char)0xc0; break;
			case L'Б': rez[i]=(char)0xc1; break;
			case L'В': rez[i]=(char)0xc2; break;
			case L'Г': rez[i]=(char)0xc3; break;
			case L'Д': rez[i]=(char)0xc4; break;
			case L'Е': rez[i]=(char)0xc5; break;
			case L'Ж': rez[i]=(char)0xc6; break;
			case L'З': rez[i]=(char)0xc7; break;
			case L'И': rez[i]=(char)0xc8; break;
			case L'Й': rez[i]=(char)0xc9; break;
			case L'К': rez[i]=(char)0xca; break;
			case L'Л': rez[i]=(char)0xcb; break;
			case L'М': rez[i]=(char)0xcc; break;
			case L'Н': rez[i]=(char)0xcd; break;
			case L'О': rez[i]=(char)0xce; break;
			case L'П': rez[i]=(char)0xcf; break;

			case L'Р': rez[i]=(char)0xd0; break;
			case L'С': rez[i]=(char)0xd1; break;
			case L'Т': rez[i]=(char)0xd2; break;
			case L'У': rez[i]=(char)0xd3; break;
			case L'Ф': rez[i]=(char)0xd4; break;
			case L'Х': rez[i]=(char)0xd5; break;
			case L'Ц': rez[i]=(char)0xd6; break;
			case L'Ч': rez[i]=(char)0xd7; break;
			case L'Ш': rez[i]=(char)0xd8; break;
			case L'Щ': rez[i]=(char)0xd9; break;
			case L'Ъ': rez[i]=(char)0xda; break;
			case L'Ы': rez[i]=(char)0xdb; break;
			case L'Ь': rez[i]=(char)0xdc; break;
			case L'Э': rez[i]=(char)0xdd; break;
			case L'Ю': rez[i]=(char)0xde; break;
			case L'Я': rez[i]=(char)0xdf; break;

			case L'а': rez[i]=(char)0xe0; break;
			case L'б': rez[i]=(char)0xe1; break;
			case L'в': rez[i]=(char)0xe2; break;
			case L'г': rez[i]=(char)0xe3; break;
			case L'д': rez[i]=(char)0xe4; break;
			case L'е': rez[i]=(char)0xe5; break;
			case L'ж': rez[i]=(char)0xe6; break;
			case L'з': rez[i]=(char)0xe7; break;
			case L'и': rez[i]=(char)0xe8; break;
			case L'й': rez[i]=(char)0xe9; break;
			case L'к': rez[i]=(char)0xea; break;
			case L'л': rez[i]=(char)0xeb; break;
			case L'м': rez[i]=(char)0xec; break;
			case L'н': rez[i]=(char)0xed; break;
			case L'о': rez[i]=(char)0xee; break;
			case L'п': rez[i]=(char)0xef; break;

			case L'р': rez[i]=(char)0xf0; break;
			case L'с': rez[i]=(char)0xf1; break;
			case L'т': rez[i]=(char)0xf2; break;
			case L'у': rez[i]=(char)0xf3; break;
			case L'ф': rez[i]=(char)0xf4; break;
			case L'х': rez[i]=(char)0xf5; break;
			case L'ц': rez[i]=(char)0xf6; break;
			case L'ч': rez[i]=(char)0xf7; break;
			case L'ш': rez[i]=(char)0xf8; break;
			case L'щ': rez[i]=(char)0xf9; break;
			case L'ъ': rez[i]=(char)0xfa; break;
			case L'ы': rez[i]=(char)0xfb; break;
			case L'ь': rez[i]=(char)0xfc; break;
			case L'э': rez[i]=(char)0xfd; break;
			case L'ю': rez[i]=(char)0xfe; break;
			case L'я': rez[i]=(char)0xff; break;
			default:
				rez[i]=0x20;
		}
	}
	return rez;
}
