Diff
Not logged in

Differences From Artifact [580294f8cd]:

To Artifact [d2578eb0fc]:


258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
    Tcl_DStringSetLength(dsPtr, oldLength + (p - string));

    return string;
}
#endif /* TCL_UTF_MAX > 3 */

char *
Tcl_Utf16ToUtfDString(
    const unsigned short *uniStr,	/* Utf-16 string to convert to UTF-8. */
    int 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;







|







258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
    Tcl_DStringSetLength(dsPtr, oldLength + (p - string));

    return string;
}
#endif /* TCL_UTF_MAX > 3 */

char *
Tcl_Char16ToUtfDString(
    const unsigned short *uniStr,	/* Utf-16 string to convert to UTF-8. */
    int 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;
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450

    *chPtr = byte;
    return 1;
}
#endif /* TCL_UTF_MAX > 3 */

int
Tcl_UtfToUtf16(
    const char *src,	/* The UTF-8 string. */
    unsigned short *chPtr)/* Filled with the Utf-16 representation of
				 * the UTF-8 string. */
{
    unsigned short byte;

    /*







|







436
437
438
439
440
441
442
443
444
445
446
447
448
449
450

    *chPtr = byte;
    return 1;
}
#endif /* TCL_UTF_MAX > 3 */

int
Tcl_UtfToChar16(
    const char *src,	/* The UTF-8 string. */
    unsigned short *chPtr)/* Filled with the Utf-16 representation of
				 * the UTF-8 string. */
{
    unsigned short byte;

    /*
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
	    oldLength + ((char *) w - (char *) wString));

    return wString;
}
#endif /* TCL_UTF_MAX > 3 */

unsigned short *
Tcl_UtfToUtf16DString(
    const char *src,		/* UTF-8 string to convert to Unicode. */
    int 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. */
{







|







607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
	    oldLength + ((char *) w - (char *) wString));

    return wString;
}
#endif /* TCL_UTF_MAX > 3 */

unsigned short *
Tcl_UtfToChar16DString(
    const char *src,		/* UTF-8 string to convert to Unicode. */
    int 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. */
{
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
	    oldLength + (int) ((length + 1) * sizeof(unsigned short)));
    wString = (unsigned short *) (Tcl_DStringValue(dsPtr) + oldLength);

    w = wString;
    p = src;
    end = src + length - 4;
    while (p < end) {
	p += Tcl_UtfToUtf16(p, &ch);
	*w++ = ch;
    }
    end += 4;
    while (p < end) {
	if (Tcl_UtfCharComplete(p, end-p)) {
	    p += Tcl_UtfToUtf16(p, &ch);
	} else {
	    ch = UCHAR(*p++);
	}
	*w++ = ch;
    }
    *w = '\0';
    Tcl_DStringSetLength(dsPtr,







|





|







638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
	    oldLength + (int) ((length + 1) * sizeof(unsigned short)));
    wString = (unsigned short *) (Tcl_DStringValue(dsPtr) + oldLength);

    w = wString;
    p = src;
    end = src + length - 4;
    while (p < end) {
	p += Tcl_UtfToChar16(p, &ch);
	*w++ = ch;
    }
    end += 4;
    while (p < end) {
	if (Tcl_UtfCharComplete(p, end-p)) {
	    p += Tcl_UtfToChar16(p, &ch);
	} else {
	    ch = UCHAR(*p++);
	}
	*w++ = ch;
    }
    *w = '\0';
    Tcl_DStringSetLength(dsPtr,
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
 *	None.
 *
 *---------------------------------------------------------------------------
 */

#if TCL_UTF_MAX == 3
#	undef Tcl_UtfToUniChar
#	define Tcl_UtfToUniChar Tcl_UtfToUtf16
#endif

int
Tcl_NumUtfChars(
    register const char *src,	/* The UTF-8 string to measure. */
    int length)			/* The length of the string in bytes, or -1
				 * for strlen(string). */







|







704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
 *	None.
 *
 *---------------------------------------------------------------------------
 */

#if TCL_UTF_MAX == 3
#	undef Tcl_UtfToUniChar
#	define Tcl_UtfToUniChar Tcl_UtfToChar16
#endif

int
Tcl_NumUtfChars(
    register const char *src,	/* The UTF-8 string to measure. */
    int length)			/* The length of the string in bytes, or -1
				 * for strlen(string). */