CString HorizonTo1250(CString str) { for (int i=0; i<str.GetLength(); i++) { switch ((unsigned char)str.GetAt(i)) { case 0xB1: str.SetAt(i,(char)0xB3); break; case 0xA1: if ( (i+1<str.GetLength())&&((unsigned char)str.GetAt(i+1)==0xE2) ) { str.SetAt(i,(char)0xA3); str.Delete(i+1); } break; case 0xE2: { if ( (i+1<str.GetLength())&&((unsigned char)str.GetAt(i+1)==0x6F) ) { str.SetAt(i,(char)0xF3); //ó str.Delete(i+1); } else if ( (i+1<str.GetLength())&&((unsigned char)str.GetAt(i+1)==0x4F) ) { str.SetAt(i,(char)0xD3); //Ó str.Delete(i+1); } else if ( (i+1<str.GetLength())&&((unsigned char)str.GetAt(i+1)==0x7A) ) { str.SetAt(i,(char)0x9F); //ź str.Delete(i+1); } else if ( (i+1<str.GetLength())&&((unsigned char)str.GetAt(i+1)==0x5A) ) { str.SetAt(i,(char)0x8F); //Ź str.Delete(i+1); } else if ( (i+1<str.GetLength())&&((unsigned char)str.GetAt(i+1)==0x63) ) { str.SetAt(i,(char)0xE6); //ć str.Delete(i+1); } else if ( (i+1<str.GetLength())&&((unsigned char)str.GetAt(i+1)==0x43) ) { str.SetAt(i,(char)0xC6); //Ć str.Delete(i+1); } else if ( (i+1<str.GetLength())&&((unsigned char)str.GetAt(i+1)==0x6E) ) { str.SetAt(i,(char)0xF1); //ń str.Delete(i+1); } else if ( (i+1<str.GetLength())&&((unsigned char)str.GetAt(i+1)==0x4E) ) { str.SetAt(i,(char)0xD1); //Ń str.Delete(i+1); } else if ( (i+1<str.GetLength())&&((unsigned char)str.GetAt(i+1)==0x73) ) { str.SetAt(i,(char)0x9C); //ś str.Delete(i+1); } else if ( (i+1<str.GetLength())&&((unsigned char)str.GetAt(i+1)==0x53) ) { str.SetAt(i,(char)0x8C); //Ś str.Delete(i+1); } } break; case 0xE7: { if ( (i+1<str.GetLength())&&((unsigned char)str.GetAt(i+1)==0x5A) ) { str.SetAt(i,(char)0xAF); //Ż str.Delete(i+1); } else if ( (i+1<str.GetLength())&&((unsigned char)str.GetAt(i+1)==0x7A) ) { str.SetAt(i,(char)0xBF); //ż str.Delete(i+1); } } break; case 0xF1: { if ( (i+1<str.GetLength())&&((unsigned char)str.GetAt(i+1)==0x65) ) { str.SetAt(i,(char)0xEA); //ę str.Delete(i+1); } else if ( (i+1<str.GetLength())&&((unsigned char)str.GetAt(i+1)==0x45) ) { str.SetAt(i,(char)0xCA); //Ę str.Delete(i+1); } else if ( (i+1<str.GetLength())&&((unsigned char)str.GetAt(i+1)==0x61) ) { str.SetAt(i,(char)0xB9); //ą str.Delete(i+1); } else if ( (i+1<str.GetLength())&&((unsigned char)str.GetAt(i+1)==0x41) ) { str.SetAt(i,(char)0xA5); //Ą str.Delete(i+1); } } break; } } return str; }
Programowanie c++/c#/delphi/javas/php/installscript/nativescript
Przykłady - przydatne funkcje
poniedziałek, 10 maja 2010
Konwersja polskich znaków z systemu Horizon na win-cp1250
Funkcja zwraca CString w formacie win-Cp1250 z polskimi znakami zakodowanymi w systemie Horizon
Etykiety:
MFC - funkcje
Subskrybuj:
Komentarze do posta (Atom)
Brak komentarzy:
Prześlij komentarz