+/*
+ * Supply implementations for some tcl functions that this module depends on
+ * to make it self contained
+ */
+
+#include "tclUniData.c"
+#define Tcl_UniChar wxChar
+
+/*
+ * Compute the uppercase equivalent of the given Unicode character.
+ * Taken from tcl.
+ */
+
+Tcl_UniChar Tcl_UniCharToUpper(int ch)
+{
+ int info = GetUniCharInfo(ch);
+
+ if (GetCaseType(info) & 0x04) {
+ return (Tcl_UniChar) (ch - GetDelta(info));
+ } else {
+ return ch;
+ }
+}
+
+/*
+ * Compute the lowercase equivalent of the given Unicode character.
+ * Taken from tcl.
+ */
+
+Tcl_UniChar Tcl_UniCharToLower(int ch)
+{
+ int info = GetUniCharInfo(ch);
+
+ if (GetCaseType(info) & 0x02) {
+ return (Tcl_UniChar) (ch + GetDelta(info));
+ } else {
+ return ch;
+ }
+}
+
+/*
+ * Compute the titlecase equivalent of the given Unicode character.
+ * Taken from tcl.
+ */
+
+Tcl_UniChar Tcl_UniCharToTitle(int ch)
+{
+ int info = GetUniCharInfo(ch);
+ int mode = GetCaseType(info);
+
+ if (mode & 0x1) {
+ /*
+ * Subtract or add one depending on the original case.
+ */
+
+ return (Tcl_UniChar) (ch + ((mode & 0x4) ? -1 : 1));
+ } else if (mode == 0x4) {
+ return (Tcl_UniChar) (ch - GetDelta(info));
+ } else {
+ return ch;
+ }
+}
+
+#else /* wxUSE_UNICODE */
+
+#include <locale.h>
+
+typedef int (*isfunc_t)(int);
+
+/* ASCII character-class table */
+static struct cclass {
+ char *name;
+ char *chars;
+ int hasch;
+ isfunc_t isfunc;
+} cclasses[] = {
+ {"alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
+0123456789", 1, isalnum},
+ {"alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
+ 1, isalpha},
+ {"blank", " \t", 0, NULL},
+ {"cntrl", "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\
+\25\26\27\30\31\32\33\34\35\36\37\177", 0, iscntrl},
+ {"digit", "0123456789", 0, isdigit},
+ {"graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
+0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
+ 1, isgraph},
+ {"lower", "abcdefghijklmnopqrstuvwxyz",
+ 1, islower},
+ {"print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
+0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ",
+ 1, isprint},
+ {"punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
+ 0, ispunct},
+ {"space", "\t\n\v\f\r ", 0, isspace},
+ {"upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
+ 0, isupper},
+ {"xdigit", "0123456789ABCDEFabcdef",
+ 0, isxdigit},
+ {NULL, 0, 0, NULL}
+};
+
+/*
+ * Supply implementations for some tcl functions that this module depends on
+ * to make it self contained
+ */
+
+#define Tcl_UniChar wxChar
+Tcl_UniChar Tcl_UniCharToUpper(int ch) { return wxToupper(ch); }
+Tcl_UniChar Tcl_UniCharToLower(int ch) { return wxTolower(ch); }
+Tcl_UniChar Tcl_UniCharToTitle(int ch) { return wxToupper(ch); }
+
+#endif /* !wxUSE_UNICODE */
+