At 10:16 PM +0200 2/24/03, Boris Segerstahl wrote:
This is interesting as a cultural difference. Here up in the North
we have always, in work and in teaching, defined ASCII as 1-255. And
yes - we always knew that Win makes a mess of 128-255. Now it is
obvious that in the US you really mean only 1-127 when you say ASCII.
I don't believe it has anything to do with where you live. Unless
you are the Red Queen (am I remembering my Lewis Carroll correctly?),
words like this don't mean whatever you want them to mean -- ASCII is
an international standard, defined by a standards body. This body
explicitly defined only 128 code points, because they wanted it to
fit uncorrupted through 7-bit pipes (which were pretty common back in
the days of modems).
So, properly speaking, ASCII really is values from 0 to 127.
Anything beyond that is not ASCII, though it may be some superset of
ASCII. The trouble is that there are lots of different supersets of
ASCII. MacRoman is one; MacIcelandic is another; MacJapanese is
another (which sometimes uses two bytes per character instead of just
one); the list goes on and on. And those are just on the Mac.
Windows has a different set of standards.
So, you can "define" ASCII as 1-255 and claim that it's Windows that
makes a mess of the values above 127, but they could just as
legitimately claim that they've defined ASCII values 1-255 and it is
YOU who is making a mess of them.
Back to RB. Chr() and Asc() are dinosaurs; they are relics from the
day when RB did not deal consistently with such encoding issues.
Their behavior was essentially undefined; on your machine, Chr(x)
might display a copyright symbol, and on mine, it might display a
Japanese hiragana. If you ever believed that "ASCII" had meaning for
these values above 127, you were fooling yourself. If you got
consistent results with them, you were lucky.
Now in RB 5, we have consistent ways of dealing with these things.
Consider Chr and Asc deprecated; they haonger have any valid use as
far as I'm concerned. But, as long as you stay in the range of ASCII
characters, they will continue to work and they will be equivalent to
Encodings.ASCII.Chr and Encodings.ASCII.Asc.
But, as soon as you start talking about values above 127, you are no
longer working in the ASCII character set. You have some other
character set in mind, and if RB had a mind-reading feature, we could
make Chr and Asc use that character set instead. But it doesn't, and
that wouldn't make for very good coding practice anyway (somebody
else reading your code might have a different character set in
mind!). So, please forget about Chr and Asc in this case. Be
explicit. Use Encodings.Whatever.Chr and Encodings.Whatever.Asc
instead. (Or, if you really mean just to work with bytes, use ChrB
and AscB.)
What is the "porting guide"?
It's a document you should find included with RB5 that talks about
this and other issues you may face when updating your projects to
RB5. I don't have a net connection at the moment so I can't give you
a more specific pointer.
As a general note (not to you, Boris, but perhaps to others): even if
you're not the sort who generally reads the "Read Me" files, I
strongly suggest you read all of them that come with RB5. A lot has
changed and you'll save yourself a lot of grief this way.
Best,
- Joe
--
,------------------------------------------------------------------.
| Joseph J. Strout REAL Software, Inc. |
| joe at realsoftware dot com http://www.realsoftware.com |
`------------------------------------------------------------------'
---
A searchable archive of this list is available at:
<http://support.realsoftware.com/listarchives/search.php>
Unsubscribe:
<mailto:realbasic-betas-off at lists dot realsoftware dot com>
Subscribe to the digest:
<mailto:realbasic-betas-digest at lists dot realsoftware dot com>
.
|