What Can't C Do? (strings)
rcd at opus.UUCP
rcd at opus.UUCP
Tue Mar 20 13:02:08 AEST 1984
<>
Articles suggesting string comparison in C so far have addressed the issues
of "does it belong there?" and such. A very different issue is that the
correct string-comparison algorithm is anything but obvious. Using the
native collating sequence - even in the ASCII part of the world - is only a
primitive solution. Text can seldom be compared "reasonably", in terms of
human expectations, with the ASCII ordering. For one thing, "dictionary
order" is different from ASCII, since it regards case of letters as less
significant than differing letters. Comparisons of names present another
problem (and a messy one) - you have to get Mc and Mac together, etc. Then
there's the language problem - for example, in Spanish "ll" and "ch" are
treated as single letters. Probably the situations in which the native
collating sequence is correct are limited to numeric comparisons (integers
only, of course) and general string comparisons where ANY order is OK as
long as it satisfies the rules of an ordering relation - as in searching,
building ordered trees, etc.
--
{hao,ucbvax,allegra}!nbires!rcd
More information about the Comp.lang.c
mailing list