summaryrefslogtreecommitdiffstats
path: root/generic/tclUtf.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2013-05-21 09:27:15 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2013-05-21 09:27:15 (GMT)
commitf193acf08ce4f3fe6db1cb79ab3589d037e5853c (patch)
treeafc89006f3988a24590c5ae650312ddb2bbf5231 /generic/tclUtf.c
parentbf486a2007f9d3d45855d43e623ad85d29bcd0b7 (diff)
downloadtcl-f193acf08ce4f3fe6db1cb79ab3589d037e5853c.zip
tcl-f193acf08ce4f3fe6db1cb79ab3589d037e5853c.tar.gz
tcl-f193acf08ce4f3fe6db1cb79ab3589d037e5853c.tar.bz2
Proposed solution for 3613609: lsort -nocase does not sort non-ASCII correctly
Diffstat (limited to 'generic/tclUtf.c')
-rw-r--r--generic/tclUtf.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/generic/tclUtf.c b/generic/tclUtf.c
index 83900e9..9dacb53 100644
--- a/generic/tclUtf.c
+++ b/generic/tclUtf.c
@@ -1101,6 +1101,33 @@ Tcl_UtfNcasecmp(
}
return 0;
}
+
+
+/* Replacement for strcasecmp in Tcl core, in places where UTF-8 should be handled. */
+int
+TclUtfCasecmp(
+ CONST char *cs, /* UTF string to compare to ct. */
+ CONST char *ct) /* UTF string cs is compared to. */
+{
+ Tcl_UniChar ch1, ch2;
+ char c;
+
+ do {
+
+ /* If c == '\0', loop should end. */
+ c = *cs;
+
+ cs += TclUtfToUniChar(cs, &ch1);
+ ct += TclUtfToUniChar(ct, &ch2);
+ if (ch1 != ch2) {
+ ch1 = Tcl_UniCharToLower(ch1);
+ ch2 = Tcl_UniCharToLower(ch2);
+ if (ch1 != ch2) break;
+ }
+ } while (c);
+ return (ch1 - ch2);
+}
+
/*
*----------------------------------------------------------------------