Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: ASCII NUL in strings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ASCII NUL in strings



email@hidden writes:
Message: 8
Date: Tue, 02 May 2006 09:15:04 -0500
From: Keith Esau <email@hidden>
Subject: Re: Escape to hex character code
To: MPW Dev <email@hidden>
Message-ID: <C07CD398.10761%email@hidden>
Content-Type: text/plain;       charset="US-ASCII"

Yeah, I've been infected too long by Unix and Windows. I forget that the old
Mac system allowed Nulls. Still, it is a very BAD idea and can frustrate the
user a lot.

<IRRELEVANT RANT ON>

It IS a bad idea, but only because the C language has come to dominate our thinking.

Virtually all languages _other_ than C have a "real" string data type of some kind, and strings are allowed to include any character. NUL is a perfectly good ASCII code that shouldn't be any different from ESC or DEL or ACK or NAK or anything else. Making one character "special" and only allowing use of 99.6% of the available character codes is an annoying asymmetry, and it is not harmless.

ASCII NUL character are (of course) allowed in strings in the Mac's native language, PASCAL; in Microsoft MFC CString objects; in C++ STL string object; in BASIC strings; etc. etc.

In my (arrogant) opinion, it is special, reserved, "sentinel" characters that are a bad idea. It was a similarly bad idea when Digital Equipment Corporation (and later CP/M and MS-DOS) decided that CTRL-Z should mark the end of a file, making it impossible for a file to include CTRL-Z characters.


As to whether non-printing characters should be included in file names, that's probably a bad idea... but it's equally bad regardless of what the character is. NUL doesn't have any special claims to evilness.

The use of a sentinel character to flag the end of a string was a clever economization for a time when C was a very lean, compact, economical language that, like FORTH, was intended to provide the most implementation bang for the byte. Over time, it increasingly looks to me like a misfeature that has cost a fair amount of grief.

<IRRELEVANT RANT OFF>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
MPW-Dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.