Re: code critique



Richard M Kreuter <kreuter@xxxxxxxxx> writes:

Daniel Leidisch <news@xxxxxxxxxxxx> writes:
In article <87r6oyigvo.fsf@xxxxxxxxxxxxxxxxxx> you wrote:

* A portability caveat: ANSI Common Lisp does not require
characters to be encoded in ASCII or any other encoding, and so
CODE-CHAR may not do what you expect here.

Do you have any suggestions as to how to implement this
more portably?

Well, this was mostly a fussy "technically this isn't portable" note;
all current implementations do, I think, use a superset of ASCII for
their character repertoires.

In case you are interested in being fussy: a conforming ANSI CL
implementation is only required to support the 96 characters in the
standard-character repertoire, and one of those characters, Newline,
need not map to a single ASCII character. You can get the standard
character for an ASCII code like this:

(defun ascii-code-char (code)
(cond ((< 31 code 127)
(char #.(format nil "~@{~A~}"
" !\"#$%&’()*+,-./0123456789:;<=>?@"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`"
"abcdefghijklmnopqrstuvwxyz{|}~")
(- code 32)))
(t ;Here you might handle Newline and the semistandard characters
(error "Can't find an ASCII character for code ~D" code))))

For the other characters in the ASCII character set, you'll need to
resort to implementation-dependent details.

There are NO other character in the ASCII character set.
There are a few control codes in the ASCII codes.



--
__Pascal Bourguignon__ http://www.informatimago.com/

NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.
.



Relevant Pages

  • Re: what does "serialization" mean?
    ... Sorry eddie, but you're dead wrong there as usual. ... >>How about ASCII character 0xB0, ... > Totalitarians and Fascists are often self-appointed language police. ...
    (comp.programming)
  • Re: what does "serialization" mean?
    ... > attempt to present myself as an authority on any and every topic I have ... >> survived and EBCDIC did not because ASCII properly sequenced letters. ... > How about ASCII character 0xB0, ... >> must assert negative facts, for all he knows is there is no knowledge ...
    (comp.programming)
  • Re: Cohens paper on byte order
    ... I think you're using "ASCII" in a notional sense. ... a good reason to teach the *opposite* convention, ... Computers should be as easy to understand as is possible _without_ ... arithmetic on character strings ...
    (sci.crypt)
  • Re: Reading a file.
    ... your program will interpret them as ASCII. ... Bruce.Eitman AT EuroTech DOT com ... buffer is character values, then in memory ASCII values are displayed. ... DWORD d = GetLastError; ...
    (microsoft.public.windowsce.app.development)
  • Re: Get ASCII values for PC arrow keys?
    ... those responsible for standards usually do attempt ... ASCII is a character set, ... ISO/IEC registry for character sets for them to receive identifying ...
    (alt.comp.lang.learn.c-cpp)