Thread View: news.software.nntp
10 messages
10 total messages
Started by Andrew Gierth
Sat, 26 Feb 2000 00:00
[NNTP Draft] 5. The WILDMAT format
Author: Andrew Gierth
Date: Sat, 26 Feb 2000 00:00
Date: Sat, 26 Feb 2000 00:00
64 lines
4253 bytes
4253 bytes
[This is one of a series of extracts from draft-ietf-nntpext-base-09.txt
which is available in full from the usual Internet-Draft archives.]
5. The WILDMAT format
Barber [Page 5]
INTERNET DRAFT November 1999
The WILDMAT format[5] described here is based on the version
first developed by Rich Salz which was derived from the format
used in the UNIX "find" command to articulate file names. It
was developed to provide a uniform mechanism for matching
patterns in the same manner that the UNIX shell matches
filenames. Patterns are implicitly anchored at the beginning
and end of each string when testing for a match. There are
five pattern-matching operations other than a strict one-to-
one match between the pattern and the source to be checked for
a match. The first is an asterisk (*) to match any sequence of
zero or more UTF-8 characters. The second is a question mark
(?) to match any single UTF-8 character. The third specifies a
specific set of characters. The set is specified as a list of
characters, or as a range of characters where the beginning
and end of the range are separated by a minus (or dash)
character, or as any combination of lists and ranges. The dash
can also be included in the set as a character it if is the
beginning or end of the set. This set is enclosed in square
brackets. The close square bracket (]) may be used in a set if
it is the first character in the set. The fourth operation is
the same as the logical not of the third operation and is
specified the same way as the third with the addition of a
caret character (^) at the beginning of the test string just
inside the open square bracket. The final operation uses the
backslash character to invalidate the special meaning of the
open square bracket ([), the asterisk, backslash, or the
question mark. The meaning of the backslash operator cannot be
negated by the exclamation point. Two backslashes in sequence
will result in the evaluation of the backslash as a character
with no special meaning.
5.1 Negating the expression
The exclamation point can be used at the beginning of a
wildmat to negate it. If it appears as any other character
other than the first one, it has no special meaning.
5.2 Examples
a) [^]-] -- matches any single character other than a
close square bracket or a minus sign/dash.
b) *bdc -- matches any string that ends with the string
"bdc" including the string "bdc" (without quotes).
c) [0-9a-zA-Z] -- matches any single printable
alphanumeric ASCII character.
d) a??d -- matches any four character string which
begins with a and ends with d.
e)!bc*d -- matches any string that does not start with
"bc" and end with "d" (without quotes)
--
Andrew.
Re: [NNTP Draft] 5. The WILDMAT format
Author: Russ Allbery
Date: Sat, 26 Feb 2000 00:00
Date: Sat, 26 Feb 2000 00:00
33 lines
2282 bytes
2282 bytes
Andrew Gierth <andrew@erlenstar.demon.co.uk> writes: > The WILDMAT format[5] described here is based on the version > first developed by Rich Salz which was derived from the format > used in the UNIX "find" command to articulate file names. [...] This paragraph badly needs to be broken up into several separate paragraphs for readability. > The third specifies a specific set of characters. The set is > specified as a list of characters, or as a range of > characters where the beginning and end of the range are > separated by a minus (or dash) character, or as any > combination of lists and ranges. The dash can also be > included in the set as a character it if is the beginning or > end of the set. This set is enclosed in square brackets. The > close square bracket (]) may be used in a set if it is the > first character in the set. In the presence of UTF-8, ranges are very poorly specified. Handling character ranges in wildcard expressions in the presence of Unicode and combining characters and the like is one of those incredibly complicated subjects that one really doesn't want to get into. I'm not sure what a good solution to this would be; in practice, character ranges are rarely used. Perhaps it would be worth just saying that character ranges are only guaranteed to be usable for ASCII characters. -- Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
Re: [NNTP Draft] 5. The WILDMAT format
Author: Curt Welch
Date: Sun, 27 Feb 2000 00:00
Date: Sun, 27 Feb 2000 00:00
15 lines
1252 bytes
1252 bytes
Kjetil Torgrim Homme <kjetilho@haey.ifi.uio.no> wrote: > > [UTF-8 everywhere] Ok, I admit it. I have no idea what UTF-8 is. Can someone point me to a standard? Is it just an 8 bit character set which is a superset of ASCII or is it something more complex (like multi-byte characters). -- Curt Welch http://CurtWelch.Com/ curt@kcwc.com Webmaster for http://NewsReader.Com/
Re: [NNTP Draft] 5. The WILDMAT format
Author: Curt Welch
Date: Sun, 27 Feb 2000 00:00
Date: Sun, 27 Feb 2000 00:00
71 lines
3486 bytes
3486 bytes
Andrew Gierth <andrew@erlenstar.demon.co.uk> wrote: > >>>>> "Curt" == Curt Welch <curt@kcwc.com> writes: > > >> > [UTF-8 everywhere] > > Curt> Ok, I admit it. I have no idea what UTF-8 is. Can someone > Curt> point me to a standard? > > RFC 2279 Thanks, time for some more homework. > Curt> Is it just an 8 bit character set which is a superset of > Curt> ASCII or is it something more complex (like multi-byte > Curt> characters). > > The latter. Ouch. > It's an encoding scheme for ISO 10646, that has these > main properties: > > - US-ASCII is a subset of UTF-8 (all strings of octet values 00-7F > are valid UTF-8 sequences representing the same characters) > > - Values 00-7F do not appear in UTF-8 other than for US-ASCII > characters > > - conversion between UTF-8 and UCS-2 or UCS-4 and back is easy > > - character boundaries are easily determined starting from any > position in a string > > - preserves the lexicographic sorting order (although this is not > culturally meaningful) > > - UTF-8 strings can be fairly reliably recognized as such by a > simple algorithm, i.e. the probability that a string of characters > in any other encoding appears as valid UTF-8 is low, diminishing > with increasing string length. Ok, that doesn't sound so bad. At the NNTP level, it seems like there's very few changes needed to support a code like that. If you don't end up with NULLS, CRs, or LFs or DOTs that aren't what they seem to be, then all the basic protocol line/data parsing will stay the same. I'm guessing that UTF-8 is not allowed in Message-IDs? I see no point in doing that. So that means it only shows up in newsgroup names in and article text right? So for newsgroup names, all you need do is extend the set of valid characters to include hex 10 to ff. That would allow for (I assume) a lot of things that were not valid UTF-8 sequences, but then it makes the server very flexible. Article text is mostly transparent to an NNTP server anyway, and if UTF-8 doesn't prevent the server from parsing the headers, then there's no change there either (execpt once again maybe making sure that the full 8 bit range of characters are allowed). So the only place I can think of where you really have to deal with the UTF-8 character parsing is in the wildmat code. That's not bad. Did I miss something? -- Curt Welch http://CurtWelch.Com/ curt@kcwc.com Webmaster for http://NewsReader.Com/
Re: [NNTP Draft] 5. The WILDMAT format
Author: Andrew Gierth
Date: Sun, 27 Feb 2000 00:00
Date: Sun, 27 Feb 2000 00:00
26 lines
2110 bytes
2110 bytes
>>>>> "Russ" == Russ Allbery <rra@stanford.edu> writes: Russ> In the presence of UTF-8, ranges are very poorly specified. Russ> Handling character ranges in wildcard expressions in the Russ> presence of Unicode and combining characters and the like is Russ> one of those incredibly complicated subjects that one really Russ> doesn't want to get into. I'm not sure what a good solution to Russ> this would be; in practice, character ranges are rarely used. Russ> Perhaps it would be worth just saying that character ranges are Russ> only guaranteed to be usable for ASCII characters. I have a trial implementation of wildmat for UTF-8 strings; implementing the character classes was not so bad (but I haven't tested it extensively yet, so I may be premature in saying that :-) Wildmat ranges are only single-character metacharacters which makes it simple. The implementation is exactly the same as before, one simply uses 32-bit variables rather than 8-bit ones (and UCS-4 only needs 31 bits, so signed 32-bit is ok) and converts UTF-8 characters into UCS-4 as they are read. OK, it doesn't really fit nicely in one hairy for() loop like the current wildmat code, but... -- Andrew.
Re: [NNTP Draft] 5. The WILDMAT format
Author: Kjetil Torgrim Homme
Date: Sun, 27 Feb 2000 00:00
Date: Sun, 27 Feb 2000 00:00
30 lines
1346 bytes
1346 bytes
> [UTF-8 everywhere] Is there any interest in specifying a MODE CHARSET extension to ease the transition to UTF-8? I would like my server to use ISO 8859-1 as default, since to my knowledge _NO_ clients support UTF-8. Basically: [C] MODE CHARSET [S] 215 list follows iso8859-1 iso8859-15 UTF-8 .. The first value reported is the current setting. The server must support "UTF-8". [C] MODE CHARSET UTF-8 [S] 204 Charset selected [C] MODE CHARSET invalid [S] 404 Unknown charset Kjetil T. PS. Yes, I have newsgroups with 8-bit characters in them.
Re: [NNTP Draft] 5. The WILDMAT format
Author: Russ Allbery
Date: Sun, 27 Feb 2000 00:00
Date: Sun, 27 Feb 2000 00:00
28 lines
1917 bytes
1917 bytes
Andrew Gierth <andrew@erlenstar.demon.co.uk> writes: > I have a trial implementation of wildmat for UTF-8 strings; implementing > the character classes was not so bad (but I haven't tested it > extensively yet, so I may be premature in saying that :-) > Wildmat ranges are only single-character metacharacters which makes it > simple. The implementation is exactly the same as before, one simply > uses 32-bit variables rather than 8-bit ones (and UCS-4 only needs 31 > bits, so signed 32-bit is ok) and converts UTF-8 characters into UCS-4 > as they are read. How hard is the conversion to UCS-4? > OK, it doesn't really fit nicely in one hairy for() loop like the > current wildmat code, but... The for loop in the current wildmat code isn't even particularly hairy. One of the truly nice things about wildmat is that it's *simple*; the only thing complex about the current code is the fail fall-through optimization. (I've considered adding a bit more intelligence to the * code so that it doesn't get quite as recursive as it currently does, though.) -- Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
Re: [NNTP Draft] 5. The WILDMAT format
Author: Andrew Gierth
Date: Sun, 27 Feb 2000 00:00
Date: Sun, 27 Feb 2000 00:00
39 lines
2115 bytes
2115 bytes
>>>>> "Curt" == Curt Welch <curt@kcwc.com> writes:
>> > [UTF-8 everywhere]
Curt> Ok, I admit it. I have no idea what UTF-8 is. Can someone
Curt> point me to a standard?
RFC 2279
Curt> Is it just an 8 bit character set which is a superset of
Curt> ASCII or is it something more complex (like multi-byte
Curt> characters).
The latter. It's an encoding scheme for ISO 10646, that has these
main properties:
- US-ASCII is a subset of UTF-8 (all strings of octet values 00-7F
are valid UTF-8 sequences representing the same characters)
- Values 00-7F do not appear in UTF-8 other than for US-ASCII
characters
- conversion between UTF-8 and UCS-2 or UCS-4 and back is easy
- character boundaries are easily determined starting from any
position in a string
- preserves the lexicographic sorting order (although this is not
culturally meaningful)
- UTF-8 strings can be fairly reliably recognized as such by a
simple algorithm, i.e. the probability that a string of characters
in any other encoding appears as valid UTF-8 is low, diminishing
with increasing string length.
--
Andrew.
Re: [NNTP Draft] 5. The WILDMAT format
Author: Kai Henningsen
Date: Sun, 05 Mar 2000 00:00
Date: Sun, 05 Mar 2000 00:00
31 lines
2091 bytes
2091 bytes
curt@kcwc.com (Curt Welch) wrote on 27.02.00 in <20000227013906.684$0P@newsreader.com>: > extend the set of valid characters to include hex 10 to ff. That would Surely at most hex 21 (space and controls not being valid) to hex fd (theoretically) or hex f5 (practically). Or, probably much better, add to whatever is currently legal the range hex 80 to hex (f5 or fd). > allow for (I assume) a lot of things that were not valid UTF-8 sequences, > but then it makes the server very flexible. > Article text is mostly transparent to an NNTP server anyway, and if UTF-8 > doesn't prevent the server from parsing the headers, then there's no It doesn't, given that CRLF, white space and : certainly stay the same. Beware signed char, though! > So the only place I can think of where you really have to deal with the > UTF-8 character parsing is in the wildmat code. That's not bad. > > Did I miss something? If there isn't something in control message handling, I don't think so. Kai -- http://www.westfalen.de/private/khms/ "... by God I *KNOW* what this network is for, and you can't have it." - Russ Allbery (rra@stanford.edu)
Re: [NNTP Draft] 5. The WILDMAT format
Author: Kai Henningsen
Date: Sun, 05 Mar 2000 00:00
Date: Sun, 05 Mar 2000 00:00
64 lines
3130 bytes
3130 bytes
rra@stanford.edu (Russ Allbery) wrote on 27.02.00 in <yld7pjxd6h.fsf@windlord.stanford.edu>:
> Andrew Gierth <andrew@erlenstar.demon.co.uk> writes:
>
> > I have a trial implementation of wildmat for UTF-8 strings; implementing
> > the character classes was not so bad (but I haven't tested it
> > extensively yet, so I may be premature in saying that :-)
>
> > Wildmat ranges are only single-character metacharacters which makes it
> > simple. The implementation is exactly the same as before, one simply
> > uses 32-bit variables rather than 8-bit ones (and UCS-4 only needs 31
> > bits, so signed 32-bit is ok) and converts UTF-8 characters into UCS-4
> > as they are read.
>
> How hard is the conversion to UCS-4?
Should be easy as long as you don't try to check for legal UTF-8 at the
same time.
Very much not optimized:
int ucs4;
char *seq, len;
if (*seq <= 0x7f) { ucs4 = *seq++; len = 0; }
else if (*seq <= 0xbf) { ucs4 = 0xfffd; len = 0; } // error case
else if (*seq <= 0xdf) { ucs4 = *seq & 0x1f; len = 1; }
else if (*seq <= 0xef) { ucs4 = *seq & 0x0f; len = 2; }
else if (*seq <= 0xf7) { ucs4 = *seq & 0x07; len = 3; }
// following cases are outside any range that will ever be allocated
// officially
else if (*seq <= 0xfb) { ucs4 = *seq & 0x03; len = 4; }
else if (*seq <= 0xfd) { ucs4 = *seq & 0x01; len = 5; }
else { ucs4 = 0xfffd; len = 0; } // error case
while (len--) {
// 0x80 <= *seq <= 0xbf
ucs4 <<= 6;
ucs4 |= (*seq++ & 0x3f);
}
That's it.
Or, to put it another way,
7 bit 0xxx xxxx
11 bit 110x xxxx 10xx xxxx
16 bit 1110 xxxx 10xx xxxx 10xx xxxx
21 bit 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx
26 bit 1111 10xx 10xx xxxx 10xx xxxx 10xx xxxx 10xx xxxx
31 bit 1111 110x 10xx xxxx 10xx xxxx 10xx xxxx 10xx xxxx 10xx xxxx
where the officially-allocatable range is 0x0000 0000 to 0x0010 ffff
(slightly over 20 bit). And 0x0000 fffd is the error char.
As for additional error checking, the rule is you must use the shortest
possible UTF8 sequence, so (say) 0xc0 0x80 is not legal for 0x00.
Kai
--
http://www.westfalen.de/private/khms/
"... by God I *KNOW* what this network is for, and you can't have it."
- Russ Allbery (rra@stanford.edu)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads