[Mono-list] conversions

Polton, Richard (IT) Richard.Polton@morganstanley.com
Tue, 5 Oct 2004 12:31:05 +0100


Thanks for this. Is it fair to say, then, that only Arabic numerals are
counted as digits?  Even though other numeric characters have integer
values?

-----Original Message-----
From: Jonathan Pryor [mailto:jonpryor@vt.edu]=20
Sent: 05 October 2004 11:32
To: Polton, Richard (IT)
Cc: Jambunathan Jambunathan; mono-list@lists.ximian.com
Subject: RE: [Mono-list] conversions

On Tue, 2004-10-05 at 04:34, Polton, Richard (IT) wrote:
>  In fact, habing given it further thought, I have a couple of
questions:
>=20
> i) if I sit at a Japanese terminal (for example) and enter '-', i.e.
> ichi or 'one', is this a valid Unicode character?

Yes.

> ii) how wide is the 'char' datatype? I assume it contains Unicode=20
> rather than single-byte ASCII.

16-bit unsigned value.  It supports Unicode.

> iii) if entering 'ichi' is valid, and char contains Unicode, then I=20
> suspect that the below subtration will return a number substantially=20
> greater than one.

No.  At least, not if it's remotely like CVS HEAD:

	public static int Val (char Expression) {
		if (char.IsDigit(Expression)) {
			return Expression - '0';
		}
		else {
			throw new ArgumentException();
		}
	}

Ichi isn't a digit, so it will generate an ArgumentException.

(Assuming that Ichi is Unicode U+4E00, which certainly looks like '-'.=20
It's in the Unicode category "Letter, Other".)

The subtraction should be safe, as (1) it's only done on digits, and (2)
Unicode follows the ASCII character ordering (for glyphs 0-127), which
permits this subtraction.

 - Jon=20
--------------------------------------------------------
=20
NOTICE: If received in error, please destroy and notify sender.  Sender =
does not waive confidentiality or privilege, and use is prohibited.=20
=20