![]() |
|
Tarih büyük harf - Baskı Önizleme +- Delphi Can (https://www.delphican.com) +-- Forum: Delphi (https://www.delphican.com/forumdisplay.php?fid=3) +--- Forum: Genel Programlama (https://www.delphican.com/forumdisplay.php?fid=6) +--- Konu Başlığı: Tarih büyük harf (/showthread.php?tid=3179) Sayfalar:
1
2
|
Tarih büyük harf - ahmetb - 20-01-2019 Merhaba, Tarihi alttaki kod ile "20 Ocak 2019 Pazar" olarak alıyorum. Büyük harf olarak nasıl alabilirim?
Caption := FormatDateTime('D MMMM YYYY DDDD', CalendarViewDate.Date);
Örnek: 20 OCAK 2019 PAZAR Tarih büyük harf - ssahinoglu - 20-01-2019 Caption := UpperCase(...); Cvp: Tarih büyük harf - hi_selamlar - 21-01-2019 (20-01-2019, Saat: 14:13)ahmetb Adlı Kullanıcıdan Alıntı: Merhaba, (20-01-2019, Saat: 14:37)ssahinoglu Adlı Kullanıcıdan Alıntı: Caption := UpperCase(...); Merhabalar, Türkçe karakterlerde sorun yaşarsınız. Onu için forum içinde biraz arama ile çözümleyebilirsiniz. http://www.delphican.com/showthread.php?tid=1954&pid=14508&highlight=t%C3%BCrk%C3%A7e+karakter#pid14508 Kolay gelsin. Tarih büyük harf - ahmetb - 21-01-2019 Cevaplar için teşekkürler. Sorum sanırım yanlış anlaşıldı ilk harf değil, tüm harfler büyük olacaktı. UpperCase Türkçe karakterde orun çıkartıyor. Bu şekilde çözmüştüm. function TFormCodes.TumHarfBuyuk(Harf: String): String; const Kucuk: String = 'abcçdefgğhıijklmnoöprsştuüvyzqw'; Buyuk: String = 'ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZQW'; var I: Integer; begin for I := 1 to length(Kucuk) do while Pos(Kucuk[I], Harf) > 0 do Harf[Pos(Kucuk[I], Harf)] := Buyuk[I]; Result := Harf; end; Cvp: Tarih büyük harf - hi_selamlar - 21-01-2019 (21-01-2019, Saat: 18:28)ahmetb Adlı Kullanıcıdan Alıntı: Cevaplar için teşekkürler. Sorum sanırım yanlış anlaşıldı ilk harf değil, tüm harfler büyük olacaktı. Merhabalar, Sorunu çözdüğünüze ve çözüm kodlarınızı da paylaştığınız için teşekkürler. Göndermiş olduğum link'i bir başlangıç oluşturması içi belirtmiştim. Kolay gelsin. Cvp: Tarih büyük harf - adelphiforumz - 21-01-2019 Döngülerle uğraşmadan kullanılabilir düşüncesindeyim Delphi hatırladığım kadarı ile Upper Converter kısmında 'ı' ve 'i' harflerinde sorun yaşıyordu Çözüm olarak aşağıdaki de aynı işi yapacaktır. UpperCase(StringReplace(StringReplace(Deger, 'ı', 'I', [rfReplaceAll, rfIgnoreCase]), 'i', 'I', [rfReplaceAll, rfIgnoreCase])); Cvp: Tarih büyük harf - Bahadir.Alkac - 21-01-2019 (21-01-2019, Saat: 19:38)adelphiforumz Adlı Kullanıcıdan Alıntı: Döngülerle uğraşmadan kullanılabilir düşüncesindeyim Merhaba, StringReplace fonksiyonu fazla karmaşık bir fonksiyon. Hele de bu kadar basit bir iş için. function StringReplace(const Source, OldPattern, NewPattern: string; Flags: TReplaceFlags): string; var Str: string; xOldPattern: string; FoundPos: Integer; I, J: Integer; SourceIdx: Integer; DestIdx: Integer; LCharsToCopy: Integer; FindCount: Integer; PosArray: array of Integer; LenOP: Integer; LenNP: Integer; LenS: Integer; ArrLen: Integer; LPResult, LPSource, LPNewPattern: PChar; LReplaceAll: Boolean; begin LenOP := Length(OldPattern); LenS := Length(Source); if (LenOP = 0) or (LenS = 0) then Exit(Source); if rfIgnoreCase in Flags then begin xOldPattern := AnsiUpperCase(OldPattern); LenOP := Length(xOldPattern); if SameStr(xOldPattern, AnsiLowerCase(OldPattern)) then // Special case, for example only symbols (+ - , * .....) Str := Source else begin Str := AnsiUpperCase(Source); LenS := Length(Str); end; end else begin xOldPattern := OldPattern; Str := Source; end; if Str.Length <> Source.Length then begin Result := ''; I := Low(string); while I <= High(Source) do begin if string.Compare(Source, I - Low(string), OldPattern, 0, LenOP, True) = 0 then begin Result := Result + NewPattern; Inc(I, LenOP); if not (rfReplaceAll in Flags) then begin Result := Result + Source.Substring(I - Low(string), MaxInt); Break; end; end else begin Result := Result + Source[I]; Inc(I); end; end; end else begin FoundPos := 1; FindCount := 0; ArrLen := 0; LReplaceAll := not (rfReplaceAll in Flags); repeat FoundPos := Pos(xOldPattern, Str, FoundPos); if FoundPos = 0 then Break; Inc(FindCount); if ArrLen < FindCount then begin if ArrLen = 0 then ArrLen := 32 else ArrLen := ArrLen * 2; SetLength(PosArray, ArrLen); // call SetLength less frequently makes a huge difference when replacing multiple occurrences end; PosArray[FindCount - 1] := FoundPos - 1; // Zero based array Inc(FoundPos, LenOP); until LReplaceAll; if FindCount > 0 then begin LenNP := Length(NewPattern); LPSource := Pointer(Source); // We use a pointer cast to avoid the _UStrToPWChar call injected by the compiler LPNewPattern := Pointer(NewPattern); // We use a pointer cast to avoid the _UStrToPWChar call injected by the compiler if LenNP = LenOP then begin // special case where Length(OldPattern) = Length(NewPattern) SetLength(Result, LenS); // in this case, we can optimize it even further LPResult := Pointer(Result); // We use a pointer cast to avoid the uniquestring call injected by the compiler Move(LPSource^, LPResult^, LenS * SizeOf(Char)); if LenNP = 1 then for I := 0 to FindCount - 1 do LPResult[PosArray[I]] := LPNewPattern^ else if LenNP <= 8 then for I := 0 to FindCount - 1 do for J := 0 to LenNP -1 do LPResult[PosArray[I] + J] := LPNewPattern[J] else for I := 0 to FindCount - 1 do Move(LPNewPattern^, LPResult[PosArray[I]], LenNP * SizeOf(Char)); end else begin SetLength(Result, LenS + ((LenNP - LenOP) * FindCount)); LPResult := Pointer(Result); // We use a pointer cast to avoid the uniquestring call injected by the compiler SourceIdx := 0; DestIdx := 0; if LenNP = 0 then for I := 0 to FindCount - 1 do begin LCharsToCopy := PosArray[I] - SourceIdx; if LCharsToCopy > 0 then begin if LCharsToCopy = 1 then begin LPResult[DestIdx] := LPSource[SourceIdx]; Inc(SourceIdx); Inc(DestIdx); end else if LCharsToCopy <= 8 then begin for J := 0 to LCharsToCopy - 1 do LPResult[DestIdx + J] := LPSource[SourceIdx + J]; Inc(SourceIdx, LCharsToCopy); Inc(DestIdx, LCharsToCopy); end else begin Move(LPSource[SourceIdx], LPResult[DestIdx], LCharsToCopy * SizeOf(Char)); Inc(SourceIdx, LCharsToCopy); Inc(DestIdx, LCharsToCopy); end; end; Inc(SourceIdx, LenOP); end else if LenNP = 1 then for I := 0 to FindCount - 1 do begin LCharsToCopy := PosArray[I] - SourceIdx; if LCharsToCopy > 0 then begin if LCharsToCopy = 1 then begin LPResult[DestIdx] := LPSource[SourceIdx]; Inc(SourceIdx); Inc(DestIdx); end else if LCharsToCopy <= 8 then begin for J := 0 to LCharsToCopy - 1 do LPResult[DestIdx + J] := LPSource[SourceIdx + J]; Inc(SourceIdx, LCharsToCopy); Inc(DestIdx, LCharsToCopy); end else begin Move(LPSource[SourceIdx], LPResult[DestIdx], LCharsToCopy * SizeOf(Char)); Inc(SourceIdx, LCharsToCopy); Inc(DestIdx, LCharsToCopy); end; end; LPResult[DestIdx] := LPNewPattern[0]; Inc(DestIdx); Inc(SourceIdx, LenOP); end else for I := 0 to FindCount - 1 do begin LCharsToCopy := PosArray[I] - SourceIdx; if LCharsToCopy > 0 then begin if LCharsToCopy = 1 then begin LPResult[DestIdx] := LPSource[SourceIdx]; Inc(SourceIdx); Inc(DestIdx); end else if LCharsToCopy <= 8 then begin for J := 0 to LCharsToCopy - 1 do LPResult[DestIdx + J] := LPSource[SourceIdx + J]; Inc(SourceIdx, LCharsToCopy); Inc(DestIdx, LCharsToCopy); end else begin Move(LPSource[SourceIdx], LPResult[DestIdx], LCharsToCopy * SizeOf(Char)); Inc(SourceIdx, LCharsToCopy); Inc(DestIdx, LCharsToCopy); end; end; Move(LPNewPattern^, LPResult[DestIdx], LenNP * SizeOf(Char)); Inc(DestIdx, LenNP); Inc(SourceIdx, LenOP); end; LCharsToCopy := LenS - SourceIdx; if LCharsToCopy > 0 then Move(LPSource[SourceIdx], LPResult[DestIdx], LCharsToCopy * SizeOf(Char)); end; end else Result := Source; end; end; Ben olsam daha basit bir fonksiyon yazardım (ki benzerlerini yazmışlığım var, ama bunu şimdi yazdım ):function TurkceBuyut(const AStr: string): string; var C, Ch: Char; begin Result := ''; for C in AStr do begin case C of 'i': Ch := 'İ'; 'ı': Ch := 'I'; 'ğ': Ch := 'Ğ'; 'ü': Ch := 'Ü'; 'ş': Ch := 'Ş'; 'ö': Ch := 'Ö'; 'ç': Ch := 'Ç'; else Ch := UpCase( C ); end; Result := Result + Ch; end; end; İyi çalışmalar Cvp: Tarih büyük harf - Fesih ARSLAN - 22-01-2019 Yorumsuz; [attachment=425] Tarih büyük harf - engerex - 22-01-2019 Eğer sadece tarih bilgileri büyültülecekse; FormatSettings.LongMonthNames[1] := 'OCAK'; FormatSettings.ShortMonthNames[1] := 'OCA'; FormatSettings.ShortDayNames[1] := 'PAZ'; FormatSettings.LongDayNames[1] := 'PAZAR'; Dezavantajı : Sistem dilini gözardı ettik. Yada bir kez sistem diline dikkat ederek; FormatSettings.LongMonthNames[1] := FormatSettings.LongMonthNames[1].ToUpper; ToUpper için Fesih Bey'e teşekkürler. Tarih büyük harf - adelphiforumz - 22-01-2019 Selamlar @Fesih ARSLAN hocamın örneğini incelerken dikkatimi çeken bir yer oldu System.Character içerisinde "function ToUpper(const S: string): string; overload; inline; deprecated 'Use TCharHelper';" şeklinde ifadeler yer alıyor buradaki "Use TCharHelper" tam olarak neyi ifade ediyor bir açıklamamı yoksa bir referans mı bu konuda bilgisi olan var mı eğer yanlış bilmiyorsam tanımlama içerisinde "deprecated" kullanımı bu yapının artık kullanılmadığını ve geriye dönük uyumluluk için ifade anlamına geliyordu http://docwiki.embarcadero.com/Libraries/Tokyo/en/System.Character.TCharHelper |