Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-01

Testing set membership for unicode chars

7 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Wimpie Nortje

Hi list

I want to test membership of a unicode char in a set / array of unicode chars. Something like

var ucCh: unicodechar;
if ucCh in [ UnicodeChar('0')..UnicodeChar('9')] then
    dosomething;

I am using fpc 2.6.0 and the '..' operator converts the data to a pascal set, which is limited to 1 byte data.

Is there another way?

Thanks
Wimpie

Paul Ishenin
to Wimpie Nortje: Hi list I want to test membership of a unicode char in a set / array of unicode chars.…

20.01.13, 23:21, Wimpie Nortje пишет:

Show quoted text 14 lines
Hi list I want to test membership of a unicode char in a set / array of unicode chars. Something like var ucCh: unicodechar; if ucCh in [ UnicodeChar('0')..UnicodeChar('9')] then dosomething; I am using fpc 2.6.0 and the '..' operator converts the data to a pascal set, which is limited to 1 byte data. Is there another way?

Delphi has CharInSet() function for this:
@TSysCharSet.html

I don't remember whether we have it in FPC at the moment.

Best regards,
Paul Ishenin

Marco van de Voort
to Paul Ishenin

In our previous episode, Paul Ishenin said:

Show quoted text 9 lines
> > I am using fpc 2.6.0 and the '..' operator converts the data to a pascal > set, which is limited to 1 byte data. > > Is there another way? Delphi has CharInSet() function for this: @TSysCharSet.html I don't remember whether we have it in FPC at the moment.

2.6.0 has it iirc, but before you point to that, it only checks the low byte. IOW it is a stop gap, not a solution for set of char in the unicode world.

Since unicode printable characters are effectively strings, if you want a pure set you will probably have to treat it as a hash or so.

Wimpie Nortje
to Marco van de Voort

Thanks, I had already written a CharInSet(UnicodeChar; UnicodeString) function, but I hoped there were a language construct equivalent to the ansi char method.

Marco van de Voort wrote 23 lines
In our previous episode, Paul Ishenin said: > > > > I am using fpc 2.6.0 and the '..' operator converts the data to a pascal > > set, which is limited to 1 byte data. > > > > Is there another way? > Delphi has CharInSet() function for this: > @TSysCharSet.html > > I don't remember whether we have it in FPC at the moment. 2.6.0 has it iirc, but before you point to that, it only checks the low byte. IOW it is a stop gap, not a solution for set of char in the unicode world. Since unicode printable characters are effectively strings, if you want a pure set you will probably have to treat it as a hash or so. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Honza
to Paul Ishenin: 20.01.13, 23:21, Wimpie Nortje пишет: Delphi has CharInSet() function for this:…

2013/1/20 Paul Ishenin :

Show quoted text 21 lines
20.01.13, 23:21, Wimpie Nortje пишет: > > Hi list > > I want to test membership of a unicode char in a set / array of unicode > chars. Something like > > var ucCh: unicodechar; > > if ucCh in [ UnicodeChar('0')..UnicodeChar('9')] then > dosomething; > > I am using fpc 2.6.0 and the '..' operator converts the data to a pascal > set, which is limited to 1 byte data. > > Is there another way? Delphi has CharInSet() function for this: @TSysCharSet.html I don't remember whether we have it in FPC at the moment.

Don't know if it can be helpful for the OP, but some years ago, I sent 'Unicode category membership checking functions' here: http://bugs.freepascal.org/view.php?id=16400

Please feel free to use that code for whatever you want w/o restrictions.

-j

Wimpie Nortje
to Honza
Honza wrote 31 lines
2013/1/20 Paul Ishenin : > 20.01.13, 23:21, Wimpie Nortje пишет: >> Hi list >> >> I want to test membership of a unicode char in a set / array of unicode >> chars. Something like >> >> var ucCh: unicodechar; >> >> if ucCh in [ UnicodeChar('0')..UnicodeChar('9')] then >> dosomething; >> >> I am using fpc 2.6.0 and the '..' operator converts the data to a pascal >> set, which is limited to 1 byte data. >> >> Is there another way? > Delphi has CharInSet() function for this: > @TSysCharSet.html > > I don't remember whether we have it in FPC at the moment. Don't know if it can be helpful for the OP, but some years ago, I sent 'Unicode category membership checking functions' here: http://bugs.freepascal.org/view.php?id=16400 Please feel free to use that code for whatever you want w/o restrictions. -j _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal