Diff
Not logged in

Differences From Artifact [2ff9e1f3ce]:

To Artifact [3b51e7483c]:


295
296
297
298
299
300
301
302
303


304
305
306
307
308
309
310
295
296
297
298
299
300
301


302
303
304
305
306
307
308
309
310







-
-
+
+







 *
 *---------------------------------------------------------------------------
 */

#undef Tcl_UniCharToUtfDString
char *
Tcl_UniCharToUtfDString(
    const int *uniStr,	/* Unicode string to convert to UTF-8. */
    size_t uniLength,		/* Length of Unicode string. */
    const int *uniStr,		/* Unicode string to convert to UTF-8. */
    ssize_t uniLength,		/* Length of Unicode string. */
    Tcl_DString *dsPtr)		/* UTF-8 representation of string is appended
				 * to this previously initialized DString. */
{
    const int *w, *wEnd;
    char *p, *string;
    size_t oldLength;

337
338
339
340
341
342
343
344

345
346
347
348
349
350
351
337
338
339
340
341
342
343

344
345
346
347
348
349
350
351







-
+








    return string;
}

char *
Tcl_Char16ToUtfDString(
    const unsigned short *uniStr,/* Utf-16 string to convert to UTF-8. */
    size_t uniLength,		/* Length of Utf-16 string. */
    ssize_t uniLength,		/* Length of Utf-16 string. */
    Tcl_DString *dsPtr)		/* UTF-8 representation of string is appended
				 * to this previously initialized DString. */
{
    const unsigned short *w, *wEnd;
    char *p, *string;
    size_t oldLength;
    int len = 1;
637
638
639
640
641
642
643
644

645
646
647
648
649
650
651
637
638
639
640
641
642
643

644
645
646
647
648
649
650
651







-
+







 *---------------------------------------------------------------------------
 */

#undef Tcl_UtfToUniCharDString
int *
Tcl_UtfToUniCharDString(
    const char *src,		/* UTF-8 string to convert to Unicode. */
    size_t length,			/* Length of UTF-8 string in bytes, or -1 for
    ssize_t length,		/* Length of UTF-8 string in bytes, or -1 for
				 * strlen(). */
    Tcl_DString *dsPtr)		/* Unicode representation of string is
				 * appended to this previously initialized
				 * DString. */
{
    int ch = 0, *w, *wString;
    const char *p;
694
695
696
697
698
699
700
701

702
703
704
705
706
707
708
694
695
696
697
698
699
700

701
702
703
704
705
706
707
708







-
+








    return wString;
}

unsigned short *
Tcl_UtfToChar16DString(
    const char *src,		/* UTF-8 string to convert to Unicode. */
    size_t length,			/* Length of UTF-8 string in bytes, or -1 for
    ssize_t length,		/* Length of UTF-8 string in bytes, or -1 for
				 * strlen(). */
    Tcl_DString *dsPtr)		/* Unicode representation of string is
				 * appended to this previously initialized
				 * DString. */
{
    unsigned short ch = 0, *w, *wString;
    const char *p;
798
799
800
801
802
803
804
805

806
807
808
809
810
811
812
798
799
800
801
802
803
804

805
806
807
808
809
810
811
812







-
+







 *
 *---------------------------------------------------------------------------
 */

size_t
Tcl_NumUtfChars(
    const char *src,	/* The UTF-8 string to measure. */
    size_t length)	/* The length of the string in bytes, or
    ssize_t length)	/* The length of the string in bytes, or
			 * TCL_INDEX_NONE for strlen(src). */
{
    Tcl_UniChar ch = 0;
    size_t i = 0;

    if (length == TCL_INDEX_NONE) {
	/* string is NUL-terminated, so TclUtfToUniChar calls are safe. */
1121
1122
1123
1124
1125
1126
1127
1128
1129


1130
1131
1132
1133
1134
1135
1136
1121
1122
1123
1124
1125
1126
1127


1128
1129
1130
1131
1132
1133
1134
1135
1136







-
-
+
+







 *	None.
 *
 *---------------------------------------------------------------------------
 */

int
Tcl_UniCharAtIndex(
    const char *src,	/* The UTF-8 string to dereference. */
    size_t index)		/* The position of the desired character. */
    const char *src,		/* The UTF-8 string to dereference. */
    ssize_t index)		/* The position of the desired character. */
{
    Tcl_UniChar ch = 0;
    int i = 0;

    if (index == TCL_INDEX_NONE) {
	return -1;
    }
1165
1166
1167
1168
1169
1170
1171
1172
1173


1174
1175
1176
1177
1178
1179
1180
1165
1166
1167
1168
1169
1170
1171


1172
1173
1174
1175
1176
1177
1178
1179
1180







-
-
+
+







 *	None.
 *
 *---------------------------------------------------------------------------
 */

const char *
Tcl_UtfAtIndex(
    const char *src,	/* The UTF-8 string. */
    size_t index)		/* The position of the desired character. */
    const char *src,		/* The UTF-8 string. */
    ssize_t index)		/* The position of the desired character. */
{
    Tcl_UniChar ch = 0;
#if TCL_UTF_MAX < 4
    size_t len = 0;
#endif

    if (index != TCL_INDEX_NONE) {