Sign in Join
Wiki copytemporary

Palindrome/de: what changed

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

Title: Palindrome/de

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+\
8+
9+# Palindrom
10+
11+\
12+Definition:\
13+Ein Palindrom ist eine Zeichenkette, die von vorn und von hinten gelesen dasselbe ergibt.\
14+\
15+= Beispiele =\
16+== Deutsch ==
17+
18+- aha
19+- Ebbe
20+- Elle
21+- Esse
22+- Neffen
23+- Otto
24+- Rentner
25+- Uhu
26+- Die Liebe ist Sieger; rege ist sie bei Leid.
27+
28+## Englisch
29+
30+- racecar
31+- A man, a plan, a canal: Panama
32+- Madam I'm Adam
33+
34+\
35+\
36+= Die Funktion IsPalindome = Diese Funktion passt für die ASCII und UTF-8 String-Codierung.\
37+
38+``` pascal
39+
40+function IsPalindome(const a_text: string): boolean;
41+var
42+ i, j :longint;
43+ s1, s2, s3 :string;
44+begin
45+ s1 := UTF8LowerCase( a_text );
46+ j := length( s1 );
47+ i := 1;
48+ s2 := '';
49+ s3 := '';
50+ while ( i <= j ) do
51+ begin
52+ if s1[i] < #$C0 then // ASCII
53+ begin
54+ if (s1[i] >= #$30) and (s1[i] < #$7B)then
55+ begin
56+ if (s1[i] > #$60) or (s1[i] < #$3A) then
57+ begin
58+ s2 := s1[i] + s2;
59+ s3 := s3 + s1[i];
60+ end;
61+ end;
62+ inc( i );
63+ end
64+ else
65+ begin
66+ begin
67+ if s1[i] < #$E0 then // two byte
68+ begin
69+ if ((s1[i] > #$C2) and ( not
70+ // Armenian punctuation
71+ ((s1[i] = #$D5) and ((s1[i+1] >= #$99) and (s1[i+1] < #$A0)))
72+ )) then
73+ begin
74+ s2 := s1[i]+ s1[i+1] + s2;
75+ s3 := s3 + s1[i] + s1[i+1];
76+ end;
77+ inc( i ,2);
78+ end
79+ else
80+ begin
81+ if s1[i] < #$F0 then // three byte
82+ begin
83+ if not (
84+ // General punctuation
85+ (s1[i] = #$E2) and ((s1[i+1]= #$80)
86+ or ((s1[i+1]= #$81) and (s1[i+2]< #$B0)))
87+ ) then
88+ begin
89+ s2 := s1[i]+ s1[i+1] + s1[i+2]+ s2;
90+ s3 := s3 + s1[i] + s1[i+1] + s1[i+2];
91+ end;
92+ inc( i ,3);
93+ end
94+ else
95+ begin
96+ s2 := s1[i]+ s1[i+1] + s1[i+2]+ s1[i+3] + s2;
97+ s3 := s3 + s1[i] + s1[i+1] + s1[i+2] + s1[i+3];
98+ inc( i ,4);
99+ end
100+ end;
101+ end;
102+ end;
103+ end;
104+ if s2 <> '' then result := s2=s3 else result := false;
105+end;
106+```
107+
108+---
109+*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