15. juni 2013 - 13:29
Der er
1 kommentar og
1 løsning
Hvor finder jeg lige mine danske tegn
Jeg har følgende kode på en form.
procedure TfrmJsCompanies.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if (ssAlt in Shift) and (CharInSet(Chr(Key), ['A'..'Z', 'Æ', 'Ø', 'Å'])) then
begin
cboStartLetters.EditValue := Chr(Key);
cboStartlettersPropertiesEditValueChanged(Self);
end;
end;
Det virker sådan set fint nok bortset fra Æ Ø og Å - hvordan får jeg lige dem med
nca
Juniormester
24. juni 2013 - 18:11
#1
Jeg har kikket på nettet og fundet nedenstående svar, som antyder, at du må skrive din kode om. Evt. kombinere ChariInSet og kontrol for ÆØÅ ved siden af.
The CharInSet "problem" is that Delphi/Pascal Sets may have a maximum of 256 elements (Cardinality) AND the base type's Cardinality must not exceed 256 either. In other words you cannot build a set like that: SomeSet = Set of 300..399; That set would have 100 members, but the base type would be Integer - which obviously has a Cardinality > 256. For the same reason you can not use Unicode Chars for set operations - which is what the compiler warning wants to tell you. CharInSet can not do "magic" either. It's only meant to be a "type safe" operator. If you are using Cyrrilic chars in Unicode then you probably have to implement IsCharSomething functions like those in unit "Character" to perform certain operations. This was all "so easy" in plain old ANSI, where you just used one of the Eastern Europe ISO encodings, which maps all your chars into the $10 - $FF area. Unicode offers much more, but it comes at a price ... You could certainly say, that the Set type is boring, but it has this limitation because it uses bits to represent each set member - and that is extremely fast ...