-typedef wx_wchar chr; /* the type itself */
-typedef unsigned long uchr; /* unsigned type that will hold a chr */
-typedef long celt; /* type to hold chr, MCCE number, or
- * NOCELT */
-
-#define NOCELT (-1) /* celt value which is not valid chr or
- * MCCE */
-#define CHR(c) ((unsigned char) (c)) /* turn char literal into chr
- * literal */
-#define DIGITVAL(c) ((c)-'0') /* turn chr digit into its value */
+typedef wxChar chr; /* the type itself */
+typedef int pchr; /* what it promotes to */
+typedef unsigned uchr; /* unsigned type that will hold a chr */
+typedef int celt; /* type to hold chr, MCCE number, or NOCELT */
+#define NOCELT (-1) /* celt value which is not valid chr or MCCE */
+#define UCHAR(c) ((unsigned char) (c))
+#define CHR(c) (UCHAR(c)) /* turn char literal into chr literal */
+#define DIGITVAL(c) ((c)-'0') /* turn chr digit into its value */
+#if !wxUSE_UNICODE
+# define CHRBITS 8 /* bits in a chr; must not use sizeof */
+# define CHR_MIN 0x00 /* smallest and largest chr; the value */
+# define CHR_MAX 0xff /* CHR_MAX-CHR_MIN+1 should fit in uchr */
+#elif SIZEOF_WCHAR_T == 4
+# define CHRBITS 32 /* bits in a chr; must not use sizeof */
+# define CHR_MIN 0x00000000 /* smallest and largest chr; the value */
+# define CHR_MAX 0xffffffff /* CHR_MAX-CHR_MIN+1 should fit in uchr */
+#else
+# define CHRBITS 16 /* bits in a chr; must not use sizeof */
+# define CHR_MIN 0x0000 /* smallest and largest chr; the value */
+# define CHR_MAX 0xffff /* CHR_MAX-CHR_MIN+1 should fit in uchr */
+#endif