piątek, 24 marca 2017

wchar_t, UnicodeString (example)





void __fastcall TForm1::Button1Click(TObject *Sender)
{
 UnicodeString days[7];
 UnicodeString upper_days[7];
 UnicodeString lower_days[7];
 int length_Days[7];

 int i;
 days[0]="Monday";
 days[1]="Tuesday";
 days[2]="Wednesday";
 days[3]="Thursday";
 days[4]="Friday";
 days[5]="Saturday";
 days[6]="Sunday";
 length_Days[0]=days[0].Length();
 length_Days[1]=days[1].Length();
 length_Days[2]=days[2].Length();
 length_Days[3]=days[3].Length();
 length_Days[4]=days[4].Length();
 length_Days[5]=days[5].Length();
 length_Days[6]=days[6].Length();
 wchar_t *Monday=new wchar_t[length_Days[0]];
 wchar_t *Tuesday=new wchar_t[length_Days[1]];
 wchar_t *Wednesday=new wchar_t[length_Days[2]];
 wchar_t *Thursday=new wchar_t[length_Days[3]];
 wchar_t *Friday=new wchar_t[length_Days[4]];
 wchar_t *Saturday=new wchar_t[length_Days[5]];
 wchar_t *Sunday=new wchar_t[length_Days[6]];
 wchar_t *u_Monday=new wchar_t[length_Days[0]];
 wchar_t *u_Tuesday=new wchar_t[length_Days[1]];
 wchar_t *u_Wednesday=new wchar_t[length_Days[2]];
 wchar_t *u_Thursday=new wchar_t[length_Days[3]];
 wchar_t *u_Friday=new wchar_t[length_Days[4]];
 wchar_t *u_Saturday=new wchar_t[length_Days[5]];
 wchar_t *u_Sunday=new wchar_t[length_Days[6]];
 wchar_t *sum_Monday=new wchar_t[2*length_Days[0]+1];
 wchar_t *sum_Tuesday=new wchar_t[2*length_Days[1]+1];
 wchar_t *sum_Wednesday=new wchar_t[2*length_Days[2]+1];
 wchar_t *sum_Thursday=new wchar_t[2*length_Days[3]+1];
 wchar_t *sum_Friday=new wchar_t[2*length_Days[4]+1];
 wchar_t *sum_Saturday=new wchar_t[2*length_Days[5]+1];
 wchar_t *sum_Sunday=new wchar_t[2*length_Days[6]+1];
 Monday=days[0].c_str();
 Tuesday=days[1].c_str();
 Wednesday=days[2].c_str();
 Thursday=days[3].c_str();
 Friday=days[4].c_str();
 Saturday=days[5].c_str();
 Sunday=days[6].c_str();
 u_Monday[length_Days[0]]='\0';
 u_Tuesday[length_Days[1]]='\0';
 u_Wednesday[length_Days[2]]='\0';
 u_Thursday[length_Days[3]]='\0';
 u_Friday[length_Days[4]]='\0';
 u_Saturday[length_Days[5]]='\0';
 u_Sunday[length_Days[6]]='\0';
 for(i=0;i<length_Days[0];i++)
  u_Monday[i]=Monday[length_Days[0]-1-i];
 for(i=0;i<length_Days[1];i++)
  u_Tuesday[i]=Tuesday[length_Days[1]-1-i];
 for(i=0;i<length_Days[2];i++)
  u_Wednesday[i]=Wednesday[length_Days[2]-1-i];
 for(i=0;i<length_Days[3];i++)
  u_Thursday[i]=Thursday[length_Days[3]-1-i];
 for(i=0;i<length_Days[4];i++)
  u_Friday[i]=Friday[length_Days[4]-1-i];
 for(i=0;i<length_Days[5];i++)
  u_Saturday[i]=Saturday[length_Days[5]-1-i];
 for(i=0;i<length_Days[6];i++)
  u_Sunday[i]=Sunday[length_Days[6]-1-i];
 wcscpy(sum_Monday,Monday);
 wcscat(sum_Monday,u_Monday);
 wcscpy(sum_Tuesday,Tuesday);
 wcscat(sum_Tuesday,u_Tuesday);
 wcscpy(sum_Wednesday,Wednesday);
 wcscat(sum_Wednesday,u_Wednesday);
 wcscpy(sum_Thursday,Thursday);
 wcscat(sum_Thursday,u_Thursday);
 wcscpy(sum_Friday,Friday);
 wcscat(sum_Friday,u_Friday);
 wcscpy(sum_Saturday,Saturday);
 wcscat(sum_Saturday,u_Saturday);
 wcscpy(sum_Sunday,Sunday);
 wcscat(sum_Sunday,u_Sunday);
 upper_days[0]=UpperCase(UnicodeString(sum_Monday));
 lower_days[0]=LowerCase(UnicodeString(sum_Monday));
 upper_days[1]=UpperCase(UnicodeString(sum_Tuesday));
 lower_days[1]=LowerCase(UnicodeString(sum_Tuesday));
 upper_days[2]=UpperCase(UnicodeString(sum_Wednesday));
 lower_days[2]=LowerCase(UnicodeString(sum_Wednesday));
 upper_days[3]=UpperCase(UnicodeString(sum_Thursday));
 lower_days[3]=LowerCase(UnicodeString(sum_Thursday));
 upper_days[4]=UpperCase(UnicodeString(sum_Friday));
 lower_days[4]=LowerCase(UnicodeString(sum_Friday));
 upper_days[5]=UpperCase(UnicodeString(sum_Saturday));
 lower_days[5]=LowerCase(UnicodeString(sum_Saturday));
 upper_days[6]=UpperCase(UnicodeString(sum_Sunday));
 lower_days[6]=LowerCase(UnicodeString(sum_Sunday));

 Edit1->Text=days[0];
 Edit2->Text=days[1];
 Edit3->Text=days[2];
 Edit4->Text=days[3];
 Edit5->Text=days[4];
 Edit6->Text=days[5];
 Edit7->Text=days[6];
 Edit8->Text=IntToStr(length_Days[0]);
 Edit9->Text=IntToStr(length_Days[1]);
 Edit10->Text=IntToStr(length_Days[2]);
 Edit11->Text=IntToStr(length_Days[3]);
 Edit12->Text=IntToStr(length_Days[4]);
 Edit13->Text=IntToStr(length_Days[5]);
 Edit14->Text=IntToStr(length_Days[6]);
 Edit15->Text=u_Monday;
 Edit16->Text=u_Tuesday;
 Edit17->Text=u_Wednesday;
 Edit18->Text=u_Thursday;
 Edit19->Text=u_Friday;
 Edit20->Text=u_Saturday;
 Edit21->Text=u_Sunday;
 Edit22->Text=sum_Monday;
 Edit23->Text=sum_Tuesday;
 Edit24->Text=sum_Wednesday;
 Edit25->Text=sum_Thursday;
 Edit26->Text=sum_Friday;
 Edit27->Text=sum_Saturday;
 Edit28->Text=sum_Sunday;
 for(i=0;i<7;i++)
 {
   ListBox1->Items->Add(upper_days[i]);
   ListBox2->Items->Add(lower_days[i]);
 }


}

Brak komentarzy:

Prześlij komentarz