Diff
Not logged in

Differences From Artifact [072d41fd6b]:

To Artifact [b1e3fb83a7]:


1
2
3
4
5
6
7
8
9
10
11

12
13
14
15
16
17
18
1
2
3
4
5
6
7
8
9
10

11
12
13
14
15
16
17
18










-
+







/*
 * tclUtf.c --
 *
 *	Routines for manipulating UTF-8 strings.
 *
 * Copyright (c) 1997-1998 Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * RCS: @(#) $Id: tclUtf.c,v 1.11 2000/01/11 22:09:00 hobbs Exp $
 * RCS: @(#) $Id: tclUtf.c,v 1.11.2.1 2001/07/16 23:14:13 hobbs Exp $
 */

#include "tclInt.h"

/*
 * Include the static character classification tables and macros.
 */
107
108
109
110
111
112
113
114

115
116
117
118
119
120
121
107
108
109
110
111
112
113

114
115
116
117
118
119
120
121







-
+







 *
 * Side effects:
 *	None.
 *
 *---------------------------------------------------------------------------
 */
 
static int
INLINE static int
UtfCount(ch)
    int ch;			/* The Tcl_UniChar whose size is returned. */
{
    if ((ch > 0) && (ch < UNICODE_SELF)) {
	return 1;
    }
    if (ch <= 0x7FF) {
777
778
779
780
781
782
783

784

785
786
787
788
789
790
791
777
778
779
780
781
782
783
784

785
786
787
788
789
790
791
792







+
-
+







				 * a backslash sequence. */
    int *readPtr;		/* Fill in with number of characters read
				 * from src, unless NULL. */
    char *dst;			/* Filled with the bytes represented by the
				 * backslash sequence. */
{
    register CONST char *p = src+1;
    Tcl_UniChar result;
    int result, count, n;
    int count, n;
    char buf[TCL_UTF_MAX];

    if (dst == NULL) {
	dst = buf;
    }

    count = 2;
879
880
881
882
883
884
885

886
887









888
889
890
891
892
893
894

895
896
897
898
899
900
901
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904

905
906
907
908
909
910
911
912







+


+
+
+
+
+
+
+
+
+






-
+







		if (!isdigit(UCHAR(*p)) || (UCHAR(*p) >= '8')) { /* INTL: digit */
		    break;
		}
		count = 4;
		result = (unsigned char)((result << 3) + (*p - '0'));
		break;
	    }
	    if (UCHAR(*p) < UNICODE_SELF) {
	    result = *p;
	    count = 2;
	    } else {
		/*
		 * We have to convert here because the user has put a
		 * backslash in front of a multi-byte utf-8 character.
		 * While this means nothing special, we shouldn't break up
		 * a correct utf-8 character. [Bug #217987] test subst-3.2
		 */
		count = Tcl_UtfToUniChar(p, &result) + 1; /* +1 for '\' */
	    }
	    break;
    }

    if (readPtr != NULL) {
	*readPtr = count;
    }
    return Tcl_UniCharToUtf(result, dst);
    return Tcl_UniCharToUtf((int) result, dst);
}

/*
 *----------------------------------------------------------------------
 *
 * Tcl_UtfToUpper --
 *