Author: Christian Cristofori
When you insert an accented letter into a HTML it should be converted into an
extended code for international use.
That will help everyone who will build an HTML editor.
Answer:
Just add this to your memo keypress event:
1
2 procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: Char);
3 const
4 UnSup =
5 #171#187#193#225#194#226#198#230#192#197#229#195#227#196#228#199#231#162#169#20
6 +
7 #233#202#234#200#232#203#235#205#237#206#238#204#236#207#239#60#209#241#211#243
8 +
9 #212#244#210#242#216#248#213#245#214#246#34#174#223#218#250#219#251#217#249#220
10 +
11 #252#255;
12 Supported: array[0..61] of string =
13 (
14 '«', '»', 'Á', 'á',
15 'Â', 'â', 'Æ', 'æ',
16 'À', 'Å', 'å', 'Ã',
17 'ã', 'Ä', 'ä', 'Ç',
18 'ç', '¢', '©', 'É',
19 'é', 'Ê', 'ê', 'È',
20 'è', 'Ë', 'ë', 'Í',
21 'í', 'Î', 'î', 'Ì',
22 'ì', 'Ï', 'ï', '<',
23 'Ñ', 'ñ', 'Ó', 'ó',
24 'Ô', 'ô', 'Ò', 'ò',
25 'Ø', 'ø', 'Õ', 'õ',
26 'Ö', 'ö', '"', '®',
27 'ß', 'Ú', 'ú', 'Û',
28 'û', 'Ù', 'ù', 'Ü',
29 'ü', 'ÿ'
30 );
31 var
32 P: Integer;
33 begin
34 P := Pos(Key, UnSup);
35 if (P > 0) then
36 begin
37 Memo1.SetSelTextBuf(PChar(Supported[P - 1]));
38 Key := #0;
39 end;
40 end;
Obviously this can be ported to every type of char substitution.
If you really use it I raccomend that you insert into the array all special symbols!
|