Rename std.ctype to std.ascii?

Jonathan M Davis jmdavisProg at gmx.com
Tue Jun 14 02:20:48 PDT 2011


On 2011-06-14 01:51, David Nadlinger wrote:
> On 6/14/11 8:23 AM, Jonathan M Davis wrote:
> >> What is your definition for ASCII character?
> >> 
> >> Most of the<ctype.h>  functions (or macros) are locale dependent, see
> >> setlocale() and<locale.h>. And there is the<wctype.h>, too.
> >> 
> >> While the C standardized ways of doing things might not be most
> >> appropriate approach in D domain, we must not base our design decisions
> >> on deficient analysis. "I just want this text uppercase" is one of the
> >> hardest things in the _world_. The problem is not just the header or
> >> package naming.
> > 
> > ??? std.ctype does _nothing_ with localization. And even if it did, that
> > doesn't change what ASCII is. ASCII is made up of the values 0 through
> > 127. And honestly, I have no clue how _those_ characters could be
> > affected by locale. Extended-ASCII might be, but I wouldn't think that
> > ASCII would be. Regardless, std.ctype does nothing with locale.
> 
> But the functions in <ctype.h> do. And there can be some
> locale-dependent problems even if you use only ASCII, the most prominent
> being the different handling of »i« in the Turkish locale:
> http://www.i18nguy.com/unicode/turkish-i18n.html
> 
> This is probably another reason why it shouldn't be called std.ctype…

From the looks of it, that affects extended ASCII but not ASCII (since the 
Turkish uppercase I isn't even in ASCII). It's definitely a great link though. 
Thanks!

It may be that we'll want to improve std.uni to deal with locales in some 
manner (either by providing new functions which handle them or altering the 
current ones to handle them), but std.ctype is pure ASCII. And while I don't 
see how locales can affect pure ASCII, ctype.h appears to actually deal with 
extended ASCII rather than just ASCII (where locales _do_ matter). So, all in 
all, std.ctype definitely has different behavior than ctype.h, which makes the 
name std.ctype that much worse.

So, given the arguably poor name of ctype and the fact that std.ctype does not 
actually match ctype.h's behavior, unless someone comes up with a really good 
reason not to fairly soon, I'm going to schedule std.ctype for deprecation and 
put the properly camelcased functions in std.ascii.

- Jonathan M Davis


More information about the Digitalmars-d mailing list