Sign in Join
Wiki copytemporary

Palindrome/de: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-<figure>
2-<img src="fpc_source_logo.png" title="fpc_source_logo.png" />
3-<figcaption>fpc_source_logo.png</figcaption>
4-</figure>
5-
6-\
7-\
1+![](/wiki-images/8/84/Fpc_source_logo.png)
82
93# Palindrom
104
11-\
125Definition:\
136Ein Palindrom ist eine Zeichenkette, die von vorn und von hinten gelesen dasselbe ergibt.\
14-\
7+
158= Beispiele =\
169== Deutsch ==
1710
1811- aha
1912- Ebbe
2013- Elle
2114- Esse
2215- Neffen
2316- Otto
2417- Rentner
2518- Uhu
2619- Die Liebe ist Sieger; rege ist sie bei Leid.
2720
2821## Englisch
2922
3023- racecar
3124- A man, a plan, a canal: Panama
3225- Madam I'm Adam
3326
34-\
35-\
3627= Die Funktion IsPalindome = Diese Funktion passt für die ASCII und UTF-8 String-Codierung.\
3728
3829``` pascal
3930
4031function IsPalindome(const a_text: string): boolean;
4132var
4233 i, j :longint;
4334 s1, s2, s3 :string;
4435begin
4536 s1 := UTF8LowerCase( a_text );
4637 j := length( s1 );
4738 i := 1;
4839 s2 := '';
4940 s3 := '';
5041 while ( i <= j ) do
5142 begin
5243 if s1[i] < #$C0 then // ASCII
5344 begin
5445 if (s1[i] >= #$30) and (s1[i] < #$7B)then
5546 begin
5647 if (s1[i] > #$60) or (s1[i] < #$3A) then
5748 begin
5849 s2 := s1[i] + s2;
5950 s3 := s3 + s1[i];
6051 end;
6152 end;
6253 inc( i );
6354 end
6455 else
6556 begin
6657 begin
6758 if s1[i] < #$E0 then // two byte
6859 begin
6960 if ((s1[i] > #$C2) and ( not
7061 // Armenian punctuation
7162 ((s1[i] = #$D5) and ((s1[i+1] >= #$99) and (s1[i+1] < #$A0)))
7263 )) then
7364 begin
7465 s2 := s1[i]+ s1[i+1] + s2;
7566 s3 := s3 + s1[i] + s1[i+1];
7667 end;
7768 inc( i ,2);
7869 end
7970 else
8071 begin
8172 if s1[i] < #$F0 then // three byte
8273 begin
8374 if not (
8475 // General punctuation
8576 (s1[i] = #$E2) and ((s1[i+1]= #$80)
8677 or ((s1[i+1]= #$81) and (s1[i+2]< #$B0)))
8778 ) then
8879 begin
8980 s2 := s1[i]+ s1[i+1] + s1[i+2]+ s2;
9081 s3 := s3 + s1[i] + s1[i+1] + s1[i+2];
9182 end;
9283 inc( i ,3);
9384 end
9485 else
9586 begin
9687 s2 := s1[i]+ s1[i+1] + s1[i+2]+ s1[i+3] + s2;
9788 s3 := s3 + s1[i] + s1[i+1] + s1[i+2] + s1[i+3];
9889 inc( i ,4);
9990 end
10091 end;
10192 end;
10293 end;
10394 end;
10495 if s2 <> '' then result := s2=s3 else result := false;
10596end;
10697```
10798
10899---
109100*From the Free Pascal wiki, page "Palindrome/de", as it stood on 2020-02-23 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history