summaryrefslogtreecommitdiffstats
path: root/generic/tclUtf.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2022-02-03 13:13:06 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2022-02-03 13:13:06 (GMT)
commit62f5155cc809b84cc59bc06780d309edaa2b59f0 (patch)
treef698c37ed975da4c6a49976ecc6821ae7ef2883c /generic/tclUtf.c
parent99678d70f78441ead651c6b62e7af986648deaeb (diff)
downloadtcl-62f5155cc809b84cc59bc06780d309edaa2b59f0.zip
tcl-62f5155cc809b84cc59bc06780d309edaa2b59f0.tar.gz
tcl-62f5155cc809b84cc59bc06780d309edaa2b59f0.tar.bz2
TIP #617: Tcl_WCharLen/Tcl_Char16Len
Diffstat (limited to 'generic/tclUtf.c')
-rw-r--r--generic/tclUtf.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/generic/tclUtf.c b/generic/tclUtf.c
index fcdf80a..fae6edd 100644
--- a/generic/tclUtf.c
+++ b/generic/tclUtf.c
@@ -1773,6 +1773,36 @@ Tcl_UniCharToTitle(
/*
*----------------------------------------------------------------------
*
+ * Tcl_Char16Len --
+ *
+ * Find the length of a UniChar string. The str input must be null
+ * terminated.
+ *
+ * Results:
+ * Returns the length of str in UniChars (not bytes).
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+Tcl_Char16Len(
+ const unsigned short *uniStr) /* Unicode string to find length of. */
+{
+ int len = 0;
+
+ while (*uniStr != '\0') {
+ len++;
+ uniStr++;
+ }
+ return len;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* Tcl_UniCharLen --
*
* Find the length of a UniChar string. The str input must be null
@@ -1787,9 +1817,10 @@ Tcl_UniCharToTitle(
*----------------------------------------------------------------------
*/
+#undef Tcl_UniCharLen
int
Tcl_UniCharLen(
- const Tcl_UniChar *uniStr) /* Unicode string to find length of. */
+ const int *uniStr) /* Unicode string to find length of. */
{
int len = 0;