Compare commits

...
14 changed files with 486 additions and 428 deletions
+11 -3
View File
@@ -2139,12 +2139,20 @@ typedef struct Tcl_EncodingType {
#define TCL_ENCODING_START 0x01
#define TCL_ENCODING_END 0x02
#define TCL_ENCODING_STOPONERROR 0x04
#define TCL_ENCODING_NO_TERMINATE 0x08
#define TCL_ENCODING_CHAR_LIMIT 0x10
#define TCL_ENCODING_MODIFIED 0x20
#define TCL_ENCODING_NOCOMPLAIN 0x40
#define TCL_ENCODING_STRICT 0x44
#if TCL_MAJOR_VERSION > 8
# define TCL_ENCODING_STOPONERROR 0
# define TCL_ENCODING_PROFILE_TCL8 (0x01 << 24)
# define TCL_ENCODING_PROFILE_STRICT (0x02 << 24)
# define TCL_ENCODING_PROFILE_REPLACE (0x03 << 24)
#else
# define TCL_ENCODING_STOPONERROR 0x04
# define TCL_ENCODING_PROFILE_TCL8 0x40
# define TCL_ENCODING_PROFILE_STRICT 0x44
# define TCL_ENCODING_PROFILE_REPLACE (0x01 << 24)
#endif
/*
* The following definitions are the error codes returned by the conversion
+177 -154
View File
@@ -51,6 +51,7 @@ static Tcl_ObjCmdProc EncodingConvertfromObjCmd;
static Tcl_ObjCmdProc EncodingConverttoObjCmd;
static Tcl_ObjCmdProc EncodingDirsObjCmd;
static Tcl_ObjCmdProc EncodingNamesObjCmd;
static Tcl_ObjCmdProc EncodingProfilesObjCmd;
static Tcl_ObjCmdProc EncodingSystemObjCmd;
static inline int ForeachAssignments(Tcl_Interp *interp,
struct ForeachState *statePtr);
@@ -519,6 +520,7 @@ TclInitEncodingCmd(
{"convertto", EncodingConverttoObjCmd, TclCompileBasic1To3ArgCmd, NULL, NULL, 0},
{"dirs", EncodingDirsObjCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 1},
{"names", EncodingNamesObjCmd, TclCompileBasic0ArgCmd, NULL, NULL, 0},
{"profiles", EncodingProfilesObjCmd, TclCompileBasic0ArgCmd, NULL, NULL, 0},
{"system", EncodingSystemObjCmd, TclCompileBasic0Or1ArgCmd, NULL, NULL, 1},
{NULL, NULL, NULL, NULL, NULL, 0}
};
@@ -526,6 +528,141 @@ TclInitEncodingCmd(
return TclMakeEnsemble(interp, "encoding", encodingImplMap);
}
/*
*------------------------------------------------------------------------
*
* EncodingConvertParseOptions --
*
* Common routine for parsing arguments passed to encoding convertfrom
* and encoding convertto.
*
* Results:
* TCL_OK or TCL_ERROR.
*
* Side effects:
* On success,
* - *encPtr is set to the encoding. Must be freed with Tcl_FreeEncoding
* if non-NULL
* - *dataObjPtr is set to the Tcl_Obj containing the data to encode or
* decode
* - *flagsPtr is set to encoding error handling flags
* - *failVarPtr is set to -failindex option value or NULL
* On error, all of the above are uninitialized.
*
*------------------------------------------------------------------------
*/
static int
EncodingConvertParseOptions (
Tcl_Interp *interp, /* For error messages. May be NULL */
int objc, /* Number of arguments */
Tcl_Obj *const objv[], /* Argument objects as passed to command. */
Tcl_Encoding *encPtr, /* Where to store the encoding */
Tcl_Obj **dataObjPtr, /* Where to store ptr to Tcl_Obj containing data */
int *flagsPtr, /* Bit mask of encoding option flags */
Tcl_Obj **failVarPtr /* Where to store -failindex option value */
)
{
static const char *const options[] = {"-profile", "-failindex", NULL};
enum convertfromOptions { PROFILE, FAILINDEX } optIndex;
#if TCL_MAJOR_VERSION > 8
static const char *const profileNames[] = {"default", "replace", "strict", "tcl8", NULL};
enum profileOptions { PROFILE_DEFAULT, PROFILE_REPLACE, PROFILE_STRICT, PROFILE_TCL8 } profile;
#else
static const char *const profileNames[] = {"replace", "strict", "tcl8", NULL};
enum profileOptions { PROFILE_DEFAULT=-1, PROFILE_REPLACE, PROFILE_STRICT, PROFILE_TCL8 } profile;
#endif
Tcl_Encoding encoding;
Tcl_Obj *dataObj;
Tcl_Obj *failVarObj;
int flags = 0;
/*
* Possible combinations:
* 1) data -> objc = 2
* 2) ?options? encoding data -> objc >= 3
* It is intentional that specifying option forces encoding to be
* specified. Less prone to user error. This should have always been
* the case even in 8.6 imho where there were no options (ie (1)
* should never have been allowed)
*/
if (objc == 1) {
numArgsError: /* ONLY jump here if nothing needs to be freed!!! */
Tcl_WrongNumArgs(interp, 1, objv,
"?-profile profile? ?-failindex var? encoding data");
((Interp *) interp)->flags |= INTERP_ALTERNATE_WRONG_ARGS;
Tcl_WrongNumArgs(interp, 1, objv, "data");
return TCL_ERROR;
}
failVarObj = NULL;
if (objc == 2) {
encoding = Tcl_GetEncoding(interp, NULL);
dataObj = objv[1];
} else {
int argIndex;
for (argIndex = 1; argIndex < (objc-2); ++argIndex) {
if (Tcl_GetIndexFromObj(
interp, objv[argIndex], options, "option", 0, &optIndex)
!= TCL_OK) {
return TCL_ERROR;
}
if (++argIndex == (objc - 2)) {
goto numArgsError;
}
switch (optIndex) {
case PROFILE:
if (Tcl_GetIndexFromObj(interp, objv[argIndex], profileNames, "profile",
0, &profile) != TCL_OK) {
return TCL_ERROR;
}
switch (profile) {
case PROFILE_TCL8:
flags = TCL_ENCODING_PROFILE_TCL8;
break;
case PROFILE_STRICT:
flags = TCL_ENCODING_PROFILE_STRICT;
break;
case PROFILE_REPLACE:
flags = TCL_ENCODING_PROFILE_REPLACE;
break;
case PROFILE_DEFAULT:
flags = TCL_ENCODING_STOPONERROR;
break;
default:
flags = 0;
break;
}
break;
case FAILINDEX:
failVarObj = objv[argIndex];
break;
}
}
/* Get encoding after opts so no need to free it on option error */
if (Tcl_GetEncodingFromObj(interp, objv[objc - 2], &encoding)
!= TCL_OK) {
return TCL_ERROR;
}
dataObj = objv[objc - 1];
}
if (failVarObj != NULL) {
/* If -failvar is specified, the default profile is PROFILE_DEFAULT, both in Tcl 8.x and 9 */
if (!flags) {
flags = TCL_ENCODING_STOPONERROR;
}
flags |= ENCODING_FAILINDEX;
}
*encPtr = encoding;
*dataObjPtr = dataObj;
*flagsPtr = flags;
*failVarPtr = failVarObj;
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
@@ -552,84 +689,13 @@ EncodingConvertfromObjCmd(
Tcl_Encoding encoding; /* Encoding to use */
int length; /* Length of the byte array being converted */
const char *bytesPtr; /* Pointer to the first byte of the array */
#if TCL_MAJOR_VERSION > 8 || defined(TCL_NO_DEPRECATED)
int flags = TCL_ENCODING_STOPONERROR;
#else
int flags = TCL_ENCODING_NOCOMPLAIN;
#endif
int flags;
int result;
Tcl_Obj *failVarObj = NULL;
/*
* Decode parameters:
* Possible combinations:
* 1) data -> objc = 2
* 2) encoding data -> objc = 3
* 3) -nocomplain data -> objc = 3
* 4) -nocomplain encoding data -> objc = 4
* 5) -strict data -> objc = 3
* 6) -strict encoding data -> objc = 4
* 7) -failindex val data -> objc = 4
* 8) -failindex val encoding data -> objc = 5
*/
Tcl_Obj *failVarObj;
if (objc == 2) {
encoding = Tcl_GetEncoding(interp, NULL);
data = objv[1];
} else if (objc > 2 && objc < 7) {
int objcUnprocessed = objc;
data = objv[objc - 1];
bytesPtr = Tcl_GetString(objv[1]);
if (bytesPtr[0] == '-' && bytesPtr[1] == 'n'
&& !strncmp(bytesPtr, "-nocomplain", strlen(bytesPtr))) {
flags = TCL_ENCODING_NOCOMPLAIN;
objcUnprocessed--;
} else if (bytesPtr[0] == '-' && bytesPtr[1] == 's'
&& !strncmp(bytesPtr, "-strict", strlen(bytesPtr))) {
flags = TCL_ENCODING_STRICT;
objcUnprocessed--;
bytesPtr = Tcl_GetString(objv[2]);
if (bytesPtr[0] == '-' && bytesPtr[1] == 'f'
&& !strncmp(bytesPtr, "-failindex", strlen(bytesPtr))) {
/* at least two additional arguments needed */
if (objc < 6) {
goto encConvFromError;
}
failVarObj = objv[3];
objcUnprocessed -= 2;
}
} else if (bytesPtr[0] == '-' && bytesPtr[1] == 'f'
&& !strncmp(bytesPtr, "-failindex", strlen(bytesPtr))) {
/* at least two additional arguments needed */
if (objc < 4) {
goto encConvFromError;
}
failVarObj = objv[2];
flags = ENCODING_FAILINDEX;
objcUnprocessed -= 2;
bytesPtr = Tcl_GetString(objv[3]);
if (bytesPtr[0] == '-' && bytesPtr[1] == 's'
&& !strncmp(bytesPtr, "-strict", strlen(bytesPtr))) {
flags = TCL_ENCODING_STRICT;
objcUnprocessed --;
}
}
switch (objcUnprocessed) {
case 3:
if (Tcl_GetEncodingFromObj(interp, objv[objc - 2], &encoding) != TCL_OK) {
return TCL_ERROR;
}
break;
case 2:
encoding = Tcl_GetEncoding(interp, NULL);
break;
default:
goto encConvFromError;
}
} else {
encConvFromError:
Tcl_WrongNumArgs(interp, 1, objv, "?-strict? ?-failindex var? ?encoding? data");
((Interp *) interp)->flags |= INTERP_ALTERNATE_WRONG_ARGS;
Tcl_WrongNumArgs(interp, 1, objv, "-nocomplain ?encoding? data");
if (EncodingConvertParseOptions(
interp, objc, objv, &encoding, &data, &flags, &failVarObj)
!= TCL_OK) {
return TCL_ERROR;
}
@@ -647,7 +713,7 @@ EncodingConvertfromObjCmd(
}
result = Tcl_ExternalToUtfDStringEx(encoding, bytesPtr, length,
flags, &ds);
if ((!(flags & TCL_ENCODING_NOCOMPLAIN) || ((flags & TCL_ENCODING_STRICT) == TCL_ENCODING_STRICT)) && (result != TCL_INDEX_NONE)) {
if ((((flags & TCL_ENCODING_NOCOMPLAIN) != TCL_ENCODING_NOCOMPLAIN) || ((flags & TCL_ENCODING_STRICT) == TCL_ENCODING_STRICT)) && (result != TCL_INDEX_NONE)) {
if (failVarObj != NULL) {
if (Tcl_ObjSetVar2(interp, failVarObj, NULL, Tcl_NewWideIntObj(result), TCL_LEAVE_ERR_MSG) == NULL) {
return TCL_ERROR;
@@ -711,83 +777,12 @@ EncodingConverttoObjCmd(
int length; /* Length of the string being converted */
const char *stringPtr; /* Pointer to the first byte of the string */
int result;
#if TCL_MAJOR_VERSION > 8 || defined(TCL_NO_DEPRECATED)
int flags = TCL_ENCODING_STOPONERROR;
#else
int flags = TCL_ENCODING_NOCOMPLAIN;
#endif
Tcl_Obj *failVarObj = NULL;
/*
* Decode parameters:
* Possible combinations:
* 1) data -> objc = 2
* 2) encoding data -> objc = 3
* 3) -nocomplain data -> objc = 3
* 4) -nocomplain encoding data -> objc = 4
* 5) -failindex val data -> objc = 4
* 6) -failindex val encoding data -> objc = 5
*/
if (objc == 2) {
encoding = Tcl_GetEncoding(interp, NULL);
data = objv[1];
} else if (objc > 2 && objc < 7) {
int objcUnprocessed = objc;
data = objv[objc - 1];
stringPtr = Tcl_GetString(objv[1]);
if (stringPtr[0] == '-' && stringPtr[1] == 'n'
&& !strncmp(stringPtr, "-nocomplain", strlen(stringPtr))) {
flags = TCL_ENCODING_NOCOMPLAIN;
objcUnprocessed--;
} else if (stringPtr[0] == '-' && stringPtr[1] == 's'
&& !strncmp(stringPtr, "-strict", strlen(stringPtr))) {
flags = TCL_ENCODING_STRICT;
objcUnprocessed--;
stringPtr = Tcl_GetString(objv[2]);
if (stringPtr[0] == '-' && stringPtr[1] == 'f'
&& !strncmp(stringPtr, "-failindex", strlen(stringPtr))) {
/* at least two additional arguments needed */
if (objc < 6) {
goto encConvToError;
}
failVarObj = objv[3];
objcUnprocessed -= 2;
}
} else if (stringPtr[0] == '-' && stringPtr[1] == 'f'
&& !strncmp(stringPtr, "-failindex", strlen(stringPtr))) {
/* at least two additional arguments needed */
if (objc < 4) {
goto encConvToError;
}
failVarObj = objv[2];
flags = TCL_ENCODING_STOPONERROR;
objcUnprocessed -= 2;
stringPtr = Tcl_GetString(objv[3]);
if (stringPtr[0] == '-' && stringPtr[1] == 's'
&& !strncmp(stringPtr, "-strict", strlen(stringPtr))) {
flags = TCL_ENCODING_STRICT;
objcUnprocessed --;
}
}
switch (objcUnprocessed) {
case 3:
if (Tcl_GetEncodingFromObj(interp, objv[objc - 2], &encoding) != TCL_OK) {
return TCL_ERROR;
}
break;
case 2:
encoding = Tcl_GetEncoding(interp, NULL);
break;
default:
goto encConvToError;
}
} else {
encConvToError:
Tcl_WrongNumArgs(interp, 1, objv, "?-strict? ?-failindex var? ?encoding? data");
((Interp *) interp)->flags |= INTERP_ALTERNATE_WRONG_ARGS;
Tcl_WrongNumArgs(interp, 1, objv, "-nocomplain ?encoding? data");
int flags;
Tcl_Obj *failVarObj;
if (EncodingConvertParseOptions(
interp, objc, objv, &encoding, &data, &flags, &failVarObj)
!= TCL_OK) {
return TCL_ERROR;
}
@@ -798,7 +793,7 @@ EncodingConverttoObjCmd(
stringPtr = TclGetStringFromObj(data, &length);
result = Tcl_UtfToExternalDStringEx(encoding, stringPtr, length,
flags, &ds);
if ((!(flags & TCL_ENCODING_NOCOMPLAIN) || ((flags & TCL_ENCODING_STRICT) == TCL_ENCODING_STRICT)) && (result != TCL_INDEX_NONE)) {
if ((((flags & TCL_ENCODING_NOCOMPLAIN) != TCL_ENCODING_NOCOMPLAIN)|| ((flags & TCL_ENCODING_STRICT) == TCL_ENCODING_STRICT)) && (result != TCL_INDEX_NONE)) {
if (failVarObj != NULL) {
/* I hope, wide int will cover size_t data type */
if (Tcl_ObjSetVar2(interp, failVarObj, NULL, Tcl_NewWideIntObj(result), TCL_LEAVE_ERR_MSG) == NULL) {
@@ -911,6 +906,34 @@ EncodingNamesObjCmd(
return TCL_OK;
}
/*
*-----------------------------------------------------------------------------
*
* EncodingProfilesObjCmd --
*
* This command returns a list of the available profiles
*
* Results:
* Returns a standard Tcl result
*
*-----------------------------------------------------------------------------
*/
int
EncodingProfilesObjCmd(
TCL_UNUSED(void *),
Tcl_Interp* interp, /* Tcl interpreter */
int objc, /* Number of command line args */
Tcl_Obj* const objv[]) /* Vector of command line args */
{
if (objc > 1) {
Tcl_WrongNumArgs(interp, 1, objv, NULL);
return TCL_ERROR;
}
Tcl_AppendResult(interp, "replace strict tcl8", NULL);
return TCL_OK;
}
/*
*-----------------------------------------------------------------------------
*
+36 -8
View File
@@ -2396,6 +2396,7 @@ UtfToUtfProc(
} else if ((UCHAR(*src) == 0xC0) && (src + 1 < srcEnd)
&& (UCHAR(src[1]) == 0x80) && !(flags & TCL_ENCODING_MODIFIED) && (!(flags & ENCODING_INPUT)
|| ((flags & TCL_ENCODING_STRICT) == TCL_ENCODING_STRICT)
|| ((flags & TCL_ENCODING_PROFILE_REPLACE) == TCL_ENCODING_PROFILE_REPLACE)
|| (flags & ENCODING_FAILINDEX))) {
/*
* If in input mode, and -strict or -failindex is specified: This is an error.
@@ -2408,7 +2409,11 @@ UtfToUtfProc(
/*
* Convert 0xC080 to real nulls when we are in output mode, with or without '-strict'.
*/
*dst++ = 0;
if (!(flags & TCL_ENCODING_MODIFIED) && (flags & TCL_ENCODING_PROFILE_REPLACE) == TCL_ENCODING_PROFILE_REPLACE) {
dst += Tcl_UniCharToUtf(0xFFFD, dst);
} else {
*dst++ = 0;
}
src += 2;
} else if (!Tcl_UtfCharComplete(src, srcEnd - src)) {
/*
@@ -2428,9 +2433,14 @@ UtfToUtfProc(
break;
}
}
char chbuf[2];
chbuf[0] = UCHAR(*src++); chbuf[1] = 0;
TclUtfToUCS4(chbuf, &ch);
if ((flags & TCL_ENCODING_PROFILE_REPLACE) == TCL_ENCODING_PROFILE_REPLACE) {
src++;
ch = 0xFFFD;
} else {
char chbuf[2];
chbuf[0] = UCHAR(*src++); chbuf[1] = 0;
TclUtfToUCS4(chbuf, &ch);
}
dst += Tcl_UniCharToUtf(ch, dst);
} else {
int low;
@@ -2442,8 +2452,11 @@ UtfToUtfProc(
} else if ((ch > 0xFFFF) && !(flags & ENCODING_UTF)
&& (((flags & TCL_ENCODING_STRICT) == TCL_ENCODING_STRICT) || (flags & ENCODING_FAILINDEX))) {
utf8Syntax:
result = TCL_CONVERT_SYNTAX;
break;
if ((flags & TCL_ENCODING_PROFILE_REPLACE) != TCL_ENCODING_PROFILE_REPLACE) {
result = TCL_CONVERT_SYNTAX;
break;
}
ch = 0xFFFD;
}
}
const char *saveSrc = src;
@@ -2473,7 +2486,9 @@ UtfToUtfProc(
if (((low & ~0x3FF) != 0xDC00) || (ch & 0x400)) {
if (STOPONERROR) {
if ((flags & TCL_ENCODING_PROFILE_REPLACE) == TCL_ENCODING_PROFILE_REPLACE) {
ch = 0xFFFD;
} else if (STOPONERROR) {
result = TCL_CONVERT_UNKNOWN;
src = saveSrc;
break;
@@ -2608,6 +2623,9 @@ Utf32ToUtfProc(
ch = 0;
break;
}
if ((flags & TCL_ENCODING_PROFILE_REPLACE) == TCL_ENCODING_PROFILE_REPLACE) {
ch = 0xFFFD;
}
}
/*
@@ -2724,6 +2742,9 @@ UtfToUtf32Proc(
result = TCL_CONVERT_UNKNOWN;
break;
}
if ((flags & TCL_ENCODING_PROFILE_STRICT) == TCL_ENCODING_PROFILE_STRICT) {
ch = 0xFFFD;
}
}
src += len;
if (flags & TCL_ENCODING_LE) {
@@ -2952,6 +2973,9 @@ UtfToUtf16Proc(
result = TCL_CONVERT_UNKNOWN;
break;
}
if ((flags & TCL_ENCODING_PROFILE_REPLACE) == TCL_ENCODING_PROFILE_REPLACE) {
ch = 0xFFFD;
}
}
src += len;
if (flags & TCL_ENCODING_LE) {
@@ -3187,7 +3211,11 @@ TableToUtfProc(
if (prefixBytes[byte]) {
src--;
}
ch = (Tcl_UniChar) byte;
if ((flags & TCL_ENCODING_PROFILE_REPLACE) == TCL_ENCODING_PROFILE_REPLACE) {
ch = 0xFFFD;
} else {
ch = (Tcl_UniChar)byte;
}
}
/*
+62 -71
View File
@@ -1680,6 +1680,9 @@ Tcl_CreateChannel(
tmp[0] = '\0';
}
statePtr->channelName = tmp;
#ifndef TCL_NO_DEPRECATED
mask |= CHANNEL_ENCODING_NOCOMPLAIN;
#endif
statePtr->flags = mask;
statePtr->maxPerms = mask; /* Save max privileges for close callback */
@@ -4398,16 +4401,19 @@ Write(
*/
if (GotFlag(statePtr, CHANNEL_ENCODING_STRICT)) {
statePtr->outputEncodingFlags &= ~(TCL_ENCODING_STRICT|TCL_ENCODING_PROFILE_REPLACE);
statePtr->outputEncodingFlags |= TCL_ENCODING_STRICT;
#ifdef TCL_NO_DEPRECATED
} else if (GotFlag(statePtr, CHANNEL_ENCODING_NOCOMPLAIN)) {
statePtr->outputEncodingFlags &= ~TCL_ENCODING_STRICT;
statePtr->outputEncodingFlags &= ~(TCL_ENCODING_STRICT|TCL_ENCODING_PROFILE_REPLACE);
statePtr->outputEncodingFlags |= TCL_ENCODING_NOCOMPLAIN;
#endif
} else {
} else if (GotFlag(statePtr, TCL_ENCODING_PROFILE_REPLACE)) {
statePtr->outputEncodingFlags &= ~TCL_ENCODING_STRICT;
statePtr->outputEncodingFlags |= TCL_ENCODING_PROFILE_REPLACE;
} else {
statePtr->outputEncodingFlags &= ~(TCL_ENCODING_STRICT|TCL_ENCODING_PROFILE_REPLACE);
}
/*
* Write the terminated escape sequence even if srcLen is 0.
*/
@@ -4735,14 +4741,16 @@ Tcl_GetsObj(
*/
if (GotFlag(statePtr, CHANNEL_ENCODING_STRICT)) {
statePtr->inputEncodingFlags &= ~(TCL_ENCODING_STRICT|TCL_ENCODING_PROFILE_REPLACE);
statePtr->inputEncodingFlags |= TCL_ENCODING_STRICT;
#ifdef TCL_NO_DEPRECATED
} else if (GotFlag(statePtr, CHANNEL_ENCODING_NOCOMPLAIN)) {
statePtr->inputEncodingFlags &= ~TCL_ENCODING_STRICT;
statePtr->inputEncodingFlags &= ~(TCL_ENCODING_STRICT|TCL_ENCODING_PROFILE_REPLACE);
statePtr->inputEncodingFlags |= TCL_ENCODING_NOCOMPLAIN;
#endif
} else {
} else if (GotFlag(statePtr, TCL_ENCODING_PROFILE_REPLACE)) {
statePtr->inputEncodingFlags &= ~TCL_ENCODING_STRICT;
statePtr->inputEncodingFlags |= TCL_ENCODING_PROFILE_REPLACE;
} else {
statePtr->inputEncodingFlags &= ~(TCL_ENCODING_STRICT|TCL_ENCODING_PROFILE_REPLACE);
}
/*
@@ -5509,14 +5517,16 @@ FilterInputBytes(
*/
if (GotFlag(statePtr, CHANNEL_ENCODING_STRICT)) {
statePtr->inputEncodingFlags &= ~(TCL_ENCODING_STRICT|TCL_ENCODING_PROFILE_REPLACE);
statePtr->inputEncodingFlags |= TCL_ENCODING_STRICT;
#ifdef TCL_NO_DEPRECATED
} else if (GotFlag(statePtr, CHANNEL_ENCODING_NOCOMPLAIN)) {
statePtr->inputEncodingFlags &= ~TCL_ENCODING_STRICT;
statePtr->inputEncodingFlags &= ~(TCL_ENCODING_STRICT|TCL_ENCODING_PROFILE_REPLACE);
statePtr->inputEncodingFlags |= TCL_ENCODING_NOCOMPLAIN;
#endif
} else {
} else if (GotFlag(statePtr, TCL_ENCODING_PROFILE_REPLACE)) {
statePtr->inputEncodingFlags &= ~TCL_ENCODING_STRICT;
statePtr->inputEncodingFlags |= TCL_ENCODING_PROFILE_REPLACE;
} else {
statePtr->inputEncodingFlags &= ~(TCL_ENCODING_STRICT|TCL_ENCODING_PROFILE_REPLACE);
}
result = Tcl_ExternalToUtf(NULL, gsPtr->encoding, raw, rawLen,
@@ -6309,14 +6319,16 @@ ReadChars(
*/
if (GotFlag(statePtr, CHANNEL_ENCODING_STRICT)) {
statePtr->inputEncodingFlags &= ~(TCL_ENCODING_STRICT|TCL_ENCODING_PROFILE_REPLACE);
statePtr->inputEncodingFlags |= TCL_ENCODING_STRICT;
#ifdef TCL_NO_DEPRECATED
} else if (GotFlag(statePtr, CHANNEL_ENCODING_NOCOMPLAIN)) {
statePtr->inputEncodingFlags &= ~TCL_ENCODING_STRICT;
statePtr->inputEncodingFlags &= ~(TCL_ENCODING_STRICT|TCL_ENCODING_PROFILE_REPLACE);
statePtr->inputEncodingFlags |= TCL_ENCODING_NOCOMPLAIN;
#endif
} else {
} else if (GotFlag(statePtr, TCL_ENCODING_PROFILE_REPLACE)) {
statePtr->inputEncodingFlags &= ~TCL_ENCODING_STRICT;
statePtr->inputEncodingFlags |= TCL_ENCODING_PROFILE_REPLACE;
} else {
statePtr->inputEncodingFlags &= ~(TCL_ENCODING_STRICT|TCL_ENCODING_PROFILE_REPLACE);
}
/*
@@ -7862,7 +7874,7 @@ Tcl_BadChannelOption(
{
if (interp != NULL) {
const char *genericopt =
"blocking buffering buffersize encoding eofchar nocomplainencoding strictencoding translation";
"blocking buffering buffersize encoding eofchar profile translation";
const char **argv;
int argc, i;
Tcl_DString ds;
@@ -8060,27 +8072,19 @@ Tcl_GetChannelOption(
return TCL_OK;
}
}
if (len == 0 || HaveOpt(1, "-nocomplainencoding")) {
if (len == 0 || HaveOpt(1, "-profile")) {
if (len == 0) {
Tcl_DStringAppendElement(dsPtr, "-nocomplainencoding");
Tcl_DStringAppendElement(dsPtr, "-profile");
}
#ifdef TCL_NO_DEPRECATED
Tcl_DStringAppendElement(dsPtr,
(flags & CHANNEL_ENCODING_NOCOMPLAIN) ? "1" : "0");
#else
Tcl_DStringAppendElement(dsPtr,
(flags & CHANNEL_ENCODING_STRICT) ? "0" : "1");
#endif
if (len > 0) {
return TCL_OK;
if (flags & CHANNEL_ENCODING_STRICT) {
Tcl_DStringAppendElement(dsPtr, "strict");
} else if (flags & TCL_ENCODING_PROFILE_REPLACE) {
Tcl_DStringAppendElement(dsPtr, "replace");
} else if (flags & CHANNEL_ENCODING_NOCOMPLAIN) {
Tcl_DStringAppendElement(dsPtr, "tcl8");
} else if (len == 0) {
Tcl_DStringAppendElement(dsPtr, "");
}
}
if (len == 0 || HaveOpt(1, "-strictencoding")) {
if (len == 0) {
Tcl_DStringAppendElement(dsPtr, "-strictencoding");
}
Tcl_DStringAppendElement(dsPtr,
(flags & CHANNEL_ENCODING_STRICT) ? "1" : "0");
if (len > 0) {
return TCL_OK;
}
@@ -8341,42 +8345,29 @@ Tcl_SetChannelOption(
ResetFlag(statePtr, CHANNEL_EOF|CHANNEL_STICKY_EOF|CHANNEL_BLOCKED);
statePtr->inputEncodingFlags &= ~TCL_ENCODING_END;
return TCL_OK;
} else if (HaveOpt(1, "-nocomplainencoding")) {
int newMode;
if (Tcl_GetBoolean(interp, newValue, &newMode) == TCL_ERROR) {
return TCL_ERROR;
}
if (newMode) {
ResetFlag(statePtr, CHANNEL_ENCODING_STRICT);
} else if (HaveOpt(1, "-profile")) {
len = strlen(newValue);
if ((newValue[0] == 't') && (strncmp(newValue, "tcl8", len) == 0)) {
ResetFlag(statePtr, CHANNEL_PROFILE);
SetFlag(statePtr, CHANNEL_ENCODING_NOCOMPLAIN);
} else {
#ifdef TCL_NO_DEPRECATED
ResetFlag(statePtr, CHANNEL_ENCODING_NOCOMPLAIN);
#else
if (GotFlag(statePtr, CHANNEL_ENCODING_STRICT) != CHANNEL_ENCODING_STRICT) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"bad value for -nocomplainencoding: only true allowed",
TCL_INDEX_NONE));
}
return TCL_ERROR;
}
#endif
}
ResetFlag(statePtr, CHANNEL_NEED_MORE_DATA|CHANNEL_ENCODING_ERROR);
return TCL_OK;
} else if (HaveOpt(1, "-strictencoding")) {
int newMode;
if (Tcl_GetBoolean(interp, newValue, &newMode) == TCL_ERROR) {
return TCL_ERROR;
}
if (newMode) {
ResetFlag(statePtr, CHANNEL_ENCODING_NOCOMPLAIN);
} else if ((newValue[0] == 's') &&
(strncmp(newValue, "strict", len) == 0)) {
ResetFlag(statePtr, CHANNEL_PROFILE);
SetFlag(statePtr, CHANNEL_ENCODING_STRICT);
} else {
ResetFlag(statePtr, CHANNEL_ENCODING_STRICT);
} else if ((newValue[0] == 'r') &&
(strncmp(newValue, "replace", len) == 0)) {
ResetFlag(statePtr, CHANNEL_PROFILE);
SetFlag(statePtr, TCL_ENCODING_PROFILE_REPLACE);
#if TCL_MAJOR_VERSION > 8
} else if ((newValue[0] == 'd') &&
(strncmp(newValue, "default", len) == 0)) {
ResetFlag(statePtr, CHANNEL_PROFILE);
#endif
} else if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"bad value for -profile: must be one of"
" replace, strict, or tcl8", TCL_INDEX_NONE));
return TCL_ERROR;
}
ResetFlag(statePtr, CHANNEL_NEED_MORE_DATA|CHANNEL_ENCODING_ERROR);
return TCL_OK;
@@ -9474,7 +9465,7 @@ TclCopyChannel(
&& outStatePtr->outputTranslation == TCL_TRANSLATE_LF
&& inStatePtr->encoding == outStatePtr->encoding
&& (inStatePtr->flags & TCL_ENCODING_STRICT) != TCL_ENCODING_STRICT
&& outStatePtr->flags & TCL_ENCODING_NOCOMPLAIN;
&& (outStatePtr->flags & TCL_ENCODING_NOCOMPLAIN) == TCL_ENCODING_NOCOMPLAIN;
/*
* Allocate a new CopyState to maintain info about the current copy in
@@ -9803,7 +9794,7 @@ CopyData(
outBinary = (outStatePtr->encoding == NULL);
sameEncoding = inStatePtr->encoding == outStatePtr->encoding
&& (inStatePtr->flags & TCL_ENCODING_STRICT) != TCL_ENCODING_STRICT
&& outStatePtr->flags & TCL_ENCODING_NOCOMPLAIN;
&& (outStatePtr->flags & TCL_ENCODING_NOCOMPLAIN) == TCL_ENCODING_NOCOMPLAIN;
if (!(inBinary || sameEncoding)) {
TclNewObj(bufObj);
+4
View File
@@ -289,6 +289,10 @@ typedef struct ChannelState {
* No further Tcl-level write IO on
* the channel is allowed. */
#define TCL_ENCODING_NOCOMPLAIN TCL_ENCODING_PROFILE_TCL8
#define TCL_ENCODING_STRICT TCL_ENCODING_PROFILE_STRICT
#define CHANNEL_PROFILE CHANNEL_ENCODING_NOCOMPLAIN|CHANNEL_ENCODING_STRICT|TCL_ENCODING_PROFILE_REPLACE
/*
* The length of time to wait between synthetic timer events. Must be zero or
* bad things tend to happen.
+3 -3
View File
@@ -252,7 +252,7 @@ test chan-io-3.3 {WriteChars: compatibility with WriteBytes: flush on line} -bod
test chan-io-3.4 {WriteChars: loop over stage buffer} -body {
# stage buffer maps to more than can be queued at once.
set f [open $path(test1) w]
chan configure $f -encoding jis0208 -buffersize 16 -nocomplainencoding 1
chan configure $f -encoding jis0208 -buffersize 16 -profile tcl8
chan puts -nonewline $f "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"
set x [list [contents $path(test1)]]
chan close $f
@@ -265,7 +265,7 @@ test chan-io-3.5 {WriteChars: saved != 0} -body {
# be moved to beginning of next channel buffer to preserve requested
# buffersize.
set f [open $path(test1) w]
chan configure $f -encoding jis0208 -buffersize 17 -nocomplainencoding 1
chan configure $f -encoding jis0208 -buffersize 17 -profile tcl8
chan puts -nonewline $f "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"
set x [list [contents $path(test1)]]
chan close $f
@@ -298,7 +298,7 @@ test chan-io-3.7 {WriteChars: (bufPtr->nextAdded > bufPtr->length)} -body {
# on flush. The truncated bytes are moved to the beginning of the next
# channel buffer.
set f [open $path(test1) w]
chan configure $f -encoding jis0208 -buffersize 17 -nocomplainencoding 1
chan configure $f -encoding jis0208 -buffersize 17 -profile tcl8
chan puts -nonewline $f "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"
set x [list [contents $path(test1)]]
chan close $f
+49 -49
View File
@@ -176,10 +176,10 @@ test cmdAH-4.1 {Tcl_EncodingObjCmd} -returnCodes error -body {
} -result {wrong # args: should be "encoding subcommand ?arg ...?"}
test cmdAH-4.2 {Tcl_EncodingObjCmd} -returnCodes error -body {
encoding foo
} -result {unknown or ambiguous subcommand "foo": must be convertfrom, convertto, dirs, names, or system}
} -result {unknown or ambiguous subcommand "foo": must be convertfrom, convertto, dirs, names, profiles, or system}
test cmdAH-4.3 {Tcl_EncodingObjCmd} -returnCodes error -body {
encoding convertto
} -result {wrong # args: should be "encoding convertto ?-strict? ?-failindex var? ?encoding? data" or "encoding convertto -nocomplain ?encoding? data"}
} -result {wrong # args: should be "encoding convertto ?-profile profile? ?-failindex var? encoding data" or "encoding convertto data"}
test cmdAH-4.4 {Tcl_EncodingObjCmd} -returnCodes error -body {
encoding convertto foo bar
} -result {unknown encoding "foo"}
@@ -201,7 +201,7 @@ test cmdAH-4.6 {Tcl_EncodingObjCmd} -setup {
} -result 8C
test cmdAH-4.7 {Tcl_EncodingObjCmd} -returnCodes error -body {
encoding convertfrom
} -result {wrong # args: should be "encoding convertfrom ?-strict? ?-failindex var? ?encoding? data" or "encoding convertfrom -nocomplain ?encoding? data"}
} -result {wrong # args: should be "encoding convertfrom ?-profile profile? ?-failindex var? encoding data" or "encoding convertfrom data"}
test cmdAH-4.8 {Tcl_EncodingObjCmd} -returnCodes error -body {
encoding convertfrom foo bar
} -result {unknown encoding "foo"}
@@ -236,33 +236,33 @@ test cmdAH-4.13 {Tcl_EncodingObjCmd} -setup {
encoding system $system
} -result iso8859-1
test cmdAH-4.14.1 {Syntax error, -nocomplain and -failindex, no encoding} -body {
encoding convertfrom -nocomplain -failindex 2 ABC
} -returnCodes 1 -result {wrong # args: should be "encoding convertfrom ?-strict? ?-failindex var? ?encoding? data" or "encoding convertfrom -nocomplain ?encoding? data"}
test cmdAH-4.14.2 {Syntax error, -nocomplain and -failindex, no encoding} -body {
encoding convertto -nocomplain -failindex 2 ABC
} -returnCodes 1 -result {wrong # args: should be "encoding convertto ?-strict? ?-failindex var? ?encoding? data" or "encoding convertto -nocomplain ?encoding? data"}
test cmdAH-4.15.1 {Syntax error, -failindex and -nocomplain, no encoding} -body {
encoding convertfrom -failindex 2 -nocomplain ABC
} -returnCodes 1 -result {unknown encoding "-nocomplain"}
test cmdAH-4.15.2 {Syntax error, -failindex and -nocomplain, no encoding} -body {
encoding convertto -failindex 2 -nocomplain ABC
} -returnCodes 1 -result {unknown encoding "-nocomplain"}
test cmdAH-4.16.1 {Syntax error, -nocomplain and -failindex, encoding} -body {
encoding convertfrom -nocomplain -failindex 2 utf-8 ABC
} -returnCodes 1 -result {wrong # args: should be "encoding convertfrom ?-strict? ?-failindex var? ?encoding? data" or "encoding convertfrom -nocomplain ?encoding? data"}
test cmdAH-4.16.2 {Syntax error, -nocomplain and -failindex, encoding} -body {
encoding convertto -nocomplain -failindex 2 utf-8 ABC
} -returnCodes 1 -result {wrong # args: should be "encoding convertto ?-strict? ?-failindex var? ?encoding? data" or "encoding convertto -nocomplain ?encoding? data"}
test cmdAH-4.17.1 {Syntax error, -failindex and -nocomplain, encoding} -body {
encoding convertfrom -failindex 2 -nocomplain utf-8 ABC
} -returnCodes 1 -result {wrong # args: should be "encoding convertfrom ?-strict? ?-failindex var? ?encoding? data" or "encoding convertfrom -nocomplain ?encoding? data"}
test cmdAH-4.17.2 {Syntax error, -failindex and -nocomplain, encoding} -body {
encoding convertto -failindex 2 -nocomplain utf-8 ABC
} -returnCodes 1 -result {wrong # args: should be "encoding convertto ?-strict? ?-failindex var? ?encoding? data" or "encoding convertto -nocomplain ?encoding? data"}
test cmdAH-4.14.1 {Syntax error, -profile tcl8 and -failindex, no encoding} -body {
encoding convertfrom -profile tcl8 -failindex 2 ABC
} -returnCodes 1 -result {wrong # args: should be "encoding convertfrom ?-profile profile? ?-failindex var? encoding data" or "encoding convertfrom data"}
test cmdAH-4.14.2 {Syntax error, -profile tcl8 and -failindex, no encoding} -body {
encoding convertto -profile tcl8 -failindex 2 ABC
} -returnCodes 1 -result {wrong # args: should be "encoding convertto ?-profile profile? ?-failindex var? encoding data" or "encoding convertto data"}
test cmdAH-4.15.1 {Syntax error, -failindex and -profile tcl8, no encoding} -body {
encoding convertfrom -failindex 2 -profile tcl8 ABC
} -returnCodes 1 -result {wrong # args: should be "encoding convertfrom ?-profile profile? ?-failindex var? encoding data" or "encoding convertfrom data"}
test cmdAH-4.15.2 {Syntax error, -failindex and -profile tcl8, no encoding} -body {
encoding convertto -failindex 2 -profile tcl8 ABC
} -returnCodes 1 -result {wrong # args: should be "encoding convertto ?-profile profile? ?-failindex var? encoding data" or "encoding convertto data"}
test cmdAH-4.16.1 {Syntax error, wrong -profile and -failindex, encoding} -body {
encoding convertfrom -profile tcl9 -failindex 2 utf-8 ABC
} -returnCodes 1 -result {bad profile "tcl9": must be replace, strict, or tcl8}
test cmdAH-4.16.2 {Syntax error, -failindex and wrong -profile, encoding} -body {
encoding convertto -failindex 2 -profile tcl9 utf-8 ABC
} -returnCodes 1 -result {bad profile "tcl9": must be replace, strict, or tcl8}
test cmdAH-4.17.1 {-failindex and -profile strict, encoding} -body {
encoding convertfrom -failindex 2 -profile strict utf-8 ABC
} -result ABC
test cmdAH-4.17.2 {-profile strict and -failindex, encoding} -body {
encoding convertto -profile strict -failindex 2 utf-8 ABC
} -result ABC
test cmdAH-4.18.1 {Syntax error, -failindex with no var, no encoding} -body {
encoding convertfrom -failindex ABC
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertfrom ?-strict? ?-failindex var? ?encoding? data" or "::tcl::encoding::convertfrom -nocomplain ?encoding? data"}
} -returnCodes 1 -result {unknown encoding "-failindex"}
test cmdAH-4.18.2 {Syntax error, -failindex with no var, no encoding (byte compiled)} -setup {
proc encoding_test {} {
encoding convertfrom -failindex ABC
@@ -270,12 +270,12 @@ test cmdAH-4.18.2 {Syntax error, -failindex with no var, no encoding (byte compi
} -body {
# Compile and execute
encoding_test
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertfrom ?-strict? ?-failindex var? ?encoding? data" or "::tcl::encoding::convertfrom -nocomplain ?encoding? data"} -cleanup {
} -returnCodes 1 -result {unknown encoding "-failindex"} -cleanup {
rename encoding_test ""
}
test cmdAH-4.18.3 {Syntax error, -failindex with no var, no encoding} -body {
encoding convertto -failindex ABC
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertto ?-strict? ?-failindex var? ?encoding? data" or "::tcl::encoding::convertto -nocomplain ?encoding? data"}
} -returnCodes 1 -result {unknown encoding "-failindex"}
test cmdAH-4.18.4 {Syntax error, -failindex with no var, no encoding (byte compiled)} -setup {
proc encoding_test {} {
encoding convertto -failindex ABC
@@ -283,16 +283,16 @@ test cmdAH-4.18.4 {Syntax error, -failindex with no var, no encoding (byte compi
} -body {
# Compile and execute
encoding_test
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertto ?-strict? ?-failindex var? ?encoding? data" or "::tcl::encoding::convertto -nocomplain ?encoding? data"} -cleanup {
} -returnCodes 1 -result {unknown encoding "-failindex"} -cleanup {
rename encoding_test ""
}
test cmdAH-4.19.1 {convertrom -failindex with correct data} -body {
encoding convertfrom -failindex test ABC
encoding convertfrom -failindex test [encoding system] ABC
set test
} -returnCodes 0 -result -1
test cmdAH-4.19.2 {convertrom -failindex with correct data (byt compiled)} -setup {
proc encoding_test {} {
encoding convertfrom -failindex test ABC
encoding convertfrom -failindex test [encoding system] ABC
set test
}
} -body {
@@ -302,12 +302,12 @@ test cmdAH-4.19.2 {convertrom -failindex with correct data (byt compiled)} -setu
rename encoding_test ""
}
test cmdAH-4.19.3 {convertrom -failindex with correct data} -body {
encoding convertto -failindex test ABC
encoding convertto -failindex test [encoding system] ABC
set test
} -returnCodes 0 -result -1
test cmdAH-4.19.4 {convertrom -failindex with correct data (byt compiled)} -setup {
proc encoding_test {} {
encoding convertto -failindex test ABC
encoding convertto -failindex test [encoding system] ABC
set test
}
} -body {
@@ -334,13 +334,13 @@ test cmdAH-4.20.2 {convertrom -failindex with incomplete utf8 (byte compiled)} -
rename encoding_test ""
}
test cmdAH-4.20.3 {convertrom -failindex with incomplete utf8} -body {
set x [encoding convertfrom -strict -failindex i utf-8 A\xc3]
set x [encoding convertfrom -profile strict -failindex i utf-8 A\xc3]
binary scan $x H* y
list $y $i
} -returnCodes 0 -result {41 1}
test cmdAH-4.20.4 {convertrom -failindex with incomplete utf8 (byte compiled)} -setup {
proc encoding_test {} {
set x [encoding convertfrom -strict -failindex i utf-8 A\xc3]
set x [encoding convertfrom -profile strict -failindex i utf-8 A\xc3]
binary scan $x H* y
list $y $i
}
@@ -351,13 +351,13 @@ test cmdAH-4.20.4 {convertrom -failindex with incomplete utf8 (byte compiled)} -
rename encoding_test ""
}
test cmdAH-4.20.5 {convertrom -failindex with incomplete utf8} -body {
set x [encoding convertfrom -failindex i -strict utf-8 A\xc3]
set x [encoding convertfrom -failindex i -profile strict utf-8 A\xc3]
binary scan $x H* y
list $y $i
} -returnCodes 0 -result {41 1}
test cmdAH-4.20.6 {convertrom -failindex with incomplete utf8 (byte compiled)} -setup {
proc encoding_test {} {
set x [encoding convertfrom -failindex i -strict utf-8 A\xc3]
set x [encoding convertfrom -failindex i -profile strict utf-8 A\xc3]
binary scan $x H* y
list $y $i
}
@@ -384,24 +384,24 @@ test cmdAH-4.21.2 {convertto -failindex with wrong character (byte compiled)} -s
} -returnCodes 0 -result {41 1} -cleanup {
rename encoding_test ""
}
test cmdAH-4.22 {convertfrom -strict} -body {
encoding convertfrom -strict utf-8 A\x00B
test cmdAH-4.22 {convertfrom -profile strict} -body {
encoding convertfrom -profile strict utf-8 A\x00B
} -result A\x00B
test cmdAH-4.23 {convertfrom -strict} -body {
encoding convertfrom -strict utf-8 A\xC0\x80B
test cmdAH-4.23 {convertfrom -profile strict} -body {
encoding convertfrom -profile strict utf-8 A\xC0\x80B
} -returnCodes error -result {unexpected byte sequence starting at index 1: '\xC0'}
test cmdAH-4.24 {convertto -strict} -body {
encoding convertto -strict utf-8 A\x00B
test cmdAH-4.24 {convertto -profile strict} -body {
encoding convertto -profile strict utf-8 A\x00B
} -result A\x00B
test cmdAH-4.25 {convertfrom -strict} -constraints knownBug -body {
encoding convertfrom -strict utf-8 A\x80B
test cmdAH-4.25 {convertfrom -profile strict} -constraints knownBug -body {
encoding convertfrom -profile strict utf-8 A\x80B
} -returnCodes error -result {unexpected byte sequence starting at index 1: '\x80'}
test cmdAH-4.26 {convertto -strict} -constraints {testbytestring knownBug} -body {
encoding convertto -strict utf-8 A[testbytestring \x80]B
test cmdAH-4.26 {convertto -profile strict} -constraints {testbytestring knownBug} -body {
encoding convertto -profile strict utf-8 A[testbytestring \x80]B
} -returnCodes error -result {unexpected byte sequence starting at index 1: '\x80'}
test cmdAH-5.1 {Tcl_FileObjCmd} -returnCodes error -body {
+88 -88
View File
@@ -299,7 +299,7 @@ test encoding-11.11 {encoding: extended Unicode UTF-32} {
test encoding-12.1 {LoadTableEncoding: normal encoding} {
set x [encoding convertto iso8859-3 Ġ]
append x [encoding convertto -nocomplain iso8859-3 Õ]
append x [encoding convertto -profile tcl8 iso8859-3 Õ]
append x [encoding convertfrom iso8859-3 Õ]
} "Õ?Ġ"
test encoding-12.2 {LoadTableEncoding: single-byte encoding} {
@@ -348,67 +348,67 @@ test encoding-15.5 {UtfToUtfProc emoji character input} {
} "4 😂"
test encoding-15.6 {UtfToUtfProc emoji character output} {
set x \uDE02\uD83D\uDE02\uD83D
set y [encoding convertto -nocomplain utf-8 \uDE02\uD83D\uDE02\uD83D]
set y [encoding convertto -profile tcl8 utf-8 \uDE02\uD83D\uDE02\uD83D]
binary scan $y H* z
list [string length $y] $z
} {10 edb882f09f9882eda0bd}
test encoding-15.7 {UtfToUtfProc emoji character output} {
set x \uDE02\uD83D\uD83D
set y [encoding convertto -nocomplain utf-8 \uDE02\uD83D\uD83D]
set y [encoding convertto -profile tcl8 utf-8 \uDE02\uD83D\uD83D]
binary scan $y H* z
list [string length $x] [string length $y] $z
} {3 9 edb882eda0bdeda0bd}
test encoding-15.8 {UtfToUtfProc emoji character output} {
set x \uDE02\uD83Dé
set y [encoding convertto -nocomplain utf-8 \uDE02\uD83Dé]
set y [encoding convertto -profile tcl8 utf-8 \uDE02\uD83Dé]
binary scan $y H* z
list [string length $x] [string length $y] $z
} {3 8 edb882eda0bdc3a9}
test encoding-15.9 {UtfToUtfProc emoji character output} {
set x \uDE02\uD83DX
set y [encoding convertto -nocomplain utf-8 \uDE02\uD83DX]
set y [encoding convertto -profile tcl8 utf-8 \uDE02\uD83DX]
binary scan $y H* z
list [string length $x] [string length $y] $z
} {3 7 edb882eda0bd58}
test encoding-15.10 {UtfToUtfProc high surrogate character output} {
set x \uDE02é
set y [encoding convertto -nocomplain utf-8 \uDE02é]
set y [encoding convertto -profile tcl8 utf-8 \uDE02é]
binary scan $y H* z
list [string length $x] [string length $y] $z
} {2 5 edb882c3a9}
test encoding-15.11 {UtfToUtfProc low surrogate character output} {
set x \uDA02é
set y [encoding convertto -nocomplain utf-8 \uDA02é]
set y [encoding convertto -profile tcl8 utf-8 \uDA02é]
binary scan $y H* z
list [string length $x] [string length $y] $z
} {2 5 eda882c3a9}
test encoding-15.12 {UtfToUtfProc high surrogate character output} {
set x \uDE02Y
set y [encoding convertto -nocomplain utf-8 \uDE02Y]
set y [encoding convertto -profile tcl8 utf-8 \uDE02Y]
binary scan $y H* z
list [string length $x] [string length $y] $z
} {2 4 edb88259}
test encoding-15.13 {UtfToUtfProc low surrogate character output} {
set x \uDA02Y
set y [encoding convertto -nocomplain utf-8 \uDA02Y]
set y [encoding convertto -profile tcl8 utf-8 \uDA02Y]
binary scan $y H* z
list [string length $x] [string length $y] $z
} {2 4 eda88259}
test encoding-15.14 {UtfToUtfProc high surrogate character output} {
set x \uDE02
set y [encoding convertto -nocomplain utf-8 \uDE02]
set y [encoding convertto -profile tcl8 utf-8 \uDE02]
binary scan $y H* z
list [string length $x] [string length $y] $z
} {1 3 edb882}
test encoding-15.15 {UtfToUtfProc low surrogate character output} {
set x \uDA02
set y [encoding convertto -nocomplain utf-8 \uDA02]
set y [encoding convertto -profile tcl8 utf-8 \uDA02]
binary scan $y H* z
list [string length $x] [string length $y] $z
} {1 3 eda882}
test encoding-15.16 {UtfToUtfProc: Invalid 4-byte UTF-8, see [ed29806ba]} {
set x \xF0\xA0\xA1\xC2
set y [encoding convertfrom -nocomplain utf-8 \xF0\xA0\xA1\xC2]
set y [encoding convertfrom -profile tcl8 utf-8 \xF0\xA0\xA1\xC2]
list [string length $x] $y
} "4 \xF0\xA0\xA1\xC2"
test encoding-15.17 {UtfToUtfProc emoji character output} {
@@ -458,20 +458,20 @@ test encoding-15.25 {UtfToUtfProc CESU-8} {
test encoding-15.26 {UtfToUtfProc CESU-8} {
encoding convertfrom cesu-8 \xC0\x80
} \x00
test encoding-15.27 {UtfToUtfProc -strict CESU-8} {
encoding convertfrom -strict cesu-8 \x00
test encoding-15.27 {UtfToUtfProc -profile strict CESU-8} {
encoding convertfrom -profile strict cesu-8 \x00
} \x00
test encoding-15.28 {UtfToUtfProc -strict CESU-8} -body {
encoding convertfrom -strict cesu-8 \xC0\x80
test encoding-15.28 {UtfToUtfProc -profile strict CESU-8} -body {
encoding convertfrom -profile strict cesu-8 \xC0\x80
} -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\xC0'}
test encoding-15.29 {UtfToUtfProc CESU-8} {
encoding convertto cesu-8 \x00
} \x00
test encoding-15.30 {UtfToUtfProc -strict CESU-8} {
encoding convertto -strict cesu-8 \x00
test encoding-15.30 {UtfToUtfProc -profile strict CESU-8} {
encoding convertto -profile strict cesu-8 \x00
} \x00
test encoding-15.31 {UtfToUtfProc -strict CESU-8 (bytes F0-F4 are invalid)} -body {
encoding convertfrom -strict cesu-8 \xF1\x86\x83\x9C
test encoding-15.31 {UtfToUtfProc -profile strict CESU-8 (bytes F0-F4 are invalid)} -body {
encoding convertfrom -profile strict cesu-8 \xF1\x86\x83\x9C
} -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\xF1'}
test encoding-16.1 {Utf16ToUtfProc} -body {
@@ -503,7 +503,7 @@ test encoding-16.7 {Utf32ToUtfProc} -body {
list $val [format %x [scan $val %c]]
} -result "乎 4e4e"
test encoding-16.8 {Utf32ToUtfProc} -body {
set val [encoding convertfrom -nocomplain utf-32 \x41\x00\x00\x41]
set val [encoding convertfrom -profile tcl8 utf-32 \x41\x00\x00\x41]
list $val [format %x [scan $val %c]]
} -result "\uFFFD fffd"
test encoding-16.9 {Utf32ToUtfProc} -body {
@@ -531,7 +531,7 @@ test encoding-16.16 {Utf16ToUtfProc} -body {
encoding convertfrom utf-16le \x00\xDC\x00\xD8
} -result \uDC00\uD800
test encoding-16.17 {Utf32ToUtfProc} -body {
list [encoding convertfrom -strict -failindex idx utf-32le \x41\x00\x00\x00\x00\xD8\x00\x00\x42\x00\x00\x00] [set idx]
list [encoding convertfrom -profile strict -failindex idx utf-32le \x41\x00\x00\x00\x00\xD8\x00\x00\x42\x00\x00\x00] [set idx]
} -result {A 4}
test encoding-16.18 {
@@ -570,10 +570,10 @@ test encoding-17.2 {UtfToUcs2Proc, invalid testcase, see [5607d6482c]} -constrai
encoding convertfrom utf-16 [encoding convertto ucs-2 "\U460DC"]
} -result "\uFFFD"
test encoding-17.3 {UtfToUtf16Proc} -body {
encoding convertto -nocomplain utf-16be "\uDCDC"
encoding convertto -profile tcl8 utf-16be "\uDCDC"
} -result "\xDC\xDC"
test encoding-17.4 {UtfToUtf16Proc} -body {
encoding convertto -nocomplain utf-16le "\uD8D8"
encoding convertto -profile tcl8 utf-16le "\uD8D8"
} -result "\xD8\xD8"
test encoding-17.5 {UtfToUtf16Proc} -body {
encoding convertto utf-32le "\U460DC"
@@ -582,54 +582,54 @@ test encoding-17.6 {UtfToUtf16Proc} -body {
encoding convertto utf-32be "\U460DC"
} -result "\x00\x04\x60\xDC"
test encoding-17.7 {UtfToUtf16Proc} -body {
encoding convertto -strict utf-16be "\uDCDC"
encoding convertto -profile strict utf-16be "\uDCDC"
} -returnCodes error -result {unexpected character at index 0: 'U+00DCDC'}
test encoding-17.8 {UtfToUtf16Proc} -body {
encoding convertto -strict utf-16le "\uD8D8"
encoding convertto -profile strict utf-16le "\uD8D8"
} -returnCodes error -result {unexpected character at index 0: 'U+00D8D8'}
test encoding-17.9 {Utf32ToUtfProc} -body {
encoding convertfrom -strict utf-32 "\xFF\xFF\xFF\xFF"
encoding convertfrom -profile strict utf-32 "\xFF\xFF\xFF\xFF"
} -returnCodes error -result {unexpected byte sequence starting at index 0: '\xFF'}
test encoding-17.10 {Utf32ToUtfProc} -body {
encoding convertfrom -nocomplain utf-32 "\xFF\xFF\xFF\xFF"
encoding convertfrom -profile tcl8 utf-32 "\xFF\xFF\xFF\xFF"
} -result \uFFFD
test encoding-18.1 {TableToUtfProc on invalid input} -constraints deprecated -body {
list [catch {encoding convertto jis0208 \\} res] $res
} -result {0 !)}
test encoding-18.2 {TableToUtfProc on invalid input with -strict} -body {
list [catch {encoding convertto -strict jis0208 \\} res] $res
test encoding-18.2 {TableToUtfProc on invalid input with -profile strict} -body {
list [catch {encoding convertto -profile strict jis0208 \\} res] $res
} -result {1 {unexpected character at index 0: 'U+00005C'}}
test encoding-18.3 {TableToUtfProc on invalid input with -strict -failindex} -body {
list [catch {encoding convertto -strict -failindex pos jis0208 \\} res] $res $pos
test encoding-18.3 {TableToUtfProc on invalid input with -profile strict -failindex} -body {
list [catch {encoding convertto -profile strict -failindex pos jis0208 \\} res] $res $pos
} -result {0 {} 0}
test encoding-18.4 {TableToUtfProc on invalid input with -failindex -strict} -body {
list [catch {encoding convertto -failindex pos -strict jis0208 \\} res] $res $pos
test encoding-18.4 {TableToUtfProc on invalid input with -failindex -profile strict} -body {
list [catch {encoding convertto -failindex pos -profile strict jis0208 \\} res] $res $pos
} -result {0 {} 0}
test encoding-18.5 {TableToUtfProc on invalid input with -failindex} -body {
list [catch {encoding convertto -failindex pos jis0208 \\} res] $res $pos
} -result {0 {} 0}
test encoding-18.6 {TableToUtfProc on invalid input with -nocomplain} -body {
list [catch {encoding convertto -nocomplain jis0208 \\} res] $res
test encoding-18.6 {TableToUtfProc on invalid input with -profile tcl8} -body {
list [catch {encoding convertto -profile tcl8 jis0208 \\} res] $res
} -result {0 !)}
test encoding-19.1 {TableFromUtfProc} -body {
encoding convertfrom ascii AÁ
} -result AÁ
test encoding-19.2 {TableFromUtfProc} -body {
encoding convertfrom -nocomplain ascii AÁ
encoding convertfrom -profile tcl8 ascii AÁ
} -result AÁ
test encoding-19.3 {TableFromUtfProc} -body {
encoding convertfrom -strict ascii AÁ
encoding convertfrom -profile strict ascii AÁ
} -returnCodes 1 -result {unexpected byte sequence starting at index 1: '\xC1'}
test encoding-19.4 {TableFromUtfProc} -body {
list [encoding convertfrom -failindex idx ascii AÁ] [set idx]
} -result {A 1}
test encoding-19.5 {TableFromUtfProc} -body {
list [encoding convertfrom -failindex idx -strict ascii AÁ] [set idx]
list [encoding convertfrom -failindex idx -profile strict ascii AÁ] [set idx]
} -result {A 1}
test encoding-19.6 {TableFromUtfProc} -body {
list [encoding convertfrom -failindex idx -strict ascii AÁB] [set idx]
list [encoding convertfrom -failindex idx -profile strict ascii AÁB] [set idx]
} -result {A 1}
test encoding-20.1 {TableFreefProc} {
@@ -742,25 +742,25 @@ test encoding-24.4 {Parse valid or invalid utf-8} {
string length [encoding convertfrom utf-8 "\xC0\x80"]
} 1
test encoding-24.5 {Parse valid or invalid utf-8} {
string length [encoding convertfrom -nocomplain utf-8 "\xC0\x81"]
string length [encoding convertfrom -profile tcl8 utf-8 "\xC0\x81"]
} 2
test encoding-24.6 {Parse valid or invalid utf-8} {
string length [encoding convertfrom -nocomplain utf-8 "\xC1\xBF"]
string length [encoding convertfrom -profile tcl8 utf-8 "\xC1\xBF"]
} 2
test encoding-24.7 {Parse valid or invalid utf-8} {
string length [encoding convertfrom utf-8 "\xC2\x80"]
} 1
test encoding-24.8 {Parse valid or invalid utf-8} {
string length [encoding convertfrom -nocomplain utf-8 "\xE0\x80\x80"]
string length [encoding convertfrom -profile tcl8 utf-8 "\xE0\x80\x80"]
} 3
test encoding-24.9 {Parse valid or invalid utf-8} {
string length [encoding convertfrom -nocomplain utf-8 "\xE0\x9F\xBF"]
string length [encoding convertfrom -profile tcl8 utf-8 "\xE0\x9F\xBF"]
} 3
test encoding-24.10 {Parse valid or invalid utf-8} {
string length [encoding convertfrom utf-8 "\xE0\xA0\x80"]
} 1
test encoding-24.11 {Parse valid or invalid utf-8} {
string length [encoding convertfrom -nocomplain utf-8 "\xEF\xBF\xBF"]
string length [encoding convertfrom -profile tcl8 utf-8 "\xEF\xBF\xBF"]
} 1
test encoding-24.12 {Parse valid or invalid utf-8} -constraints deprecated -body {
encoding convertfrom utf-8 "\xC0\x81"
@@ -786,83 +786,83 @@ test encoding-24.18 {Parse valid or invalid utf-8} -constraints testbytestring -
test encoding-24.19 {Parse valid or invalid utf-8} -constraints deprecated -body {
encoding convertto utf-8 "ZX\uD800"
} -result ZX\xED\xA0\x80
test encoding-24.20 {Parse with -nocomplain but without providing encoding} {
string length [encoding convertfrom -nocomplain "\x20"]
} 1
test encoding-24.21 {Parse with -nocomplain but without providing encoding} {
string length [encoding convertto -nocomplain "\x20"]
} 1
test encoding-24.20 {Parse with -profile tcl8 but without providing encoding} -body {
encoding convertfrom -profile tcl8 "\x20"
} -result {wrong # args: should be "::tcl::encoding::convertfrom ?-profile profile? ?-failindex var? encoding data" or "::tcl::encoding::convertfrom data"} -returnCodes error
test encoding-24.21 {Parse with -profile tcl8 but without providing encoding} -body {
string length [encoding convertto -profile tcl8 "\x20"]
} -result {wrong # args: should be "::tcl::encoding::convertto ?-profile profile? ?-failindex var? encoding data" or "::tcl::encoding::convertto data"} -returnCodes error
test encoding-24.22 {Syntax error, two encodings} -body {
encoding convertfrom iso8859-1 utf-8 "ZX\uD800"
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertfrom ?-strict? ?-failindex var? ?encoding? data" or "::tcl::encoding::convertfrom -nocomplain ?encoding? data"}
} -result {bad option "iso8859-1": must be -profile or -failindex} -returnCodes error
test encoding-24.23 {Syntax error, two encodings} -body {
encoding convertto iso8859-1 utf-8 "ZX\uD800"
} -returnCodes 1 -result {wrong # args: should be "::tcl::encoding::convertto ?-strict? ?-failindex var? ?encoding? data" or "::tcl::encoding::convertto -nocomplain ?encoding? data"}
test encoding-24.24 {Parse invalid utf-8 with -strict} -body {
encoding convertfrom -strict utf-8 "\xC0\x80\x00\x00"
} -result {bad option "iso8859-1": must be -profile or -failindex} -returnCodes error
test encoding-24.24 {Parse invalid utf-8 with -profile strict} -body {
encoding convertfrom -profile strict utf-8 "\xC0\x80\x00\x00"
} -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\xC0'}
test encoding-24.25 {Parse invalid utf-8 with -strict} -body {
encoding convertfrom -strict utf-8 "\x40\x80\x00\x00"
test encoding-24.25 {Parse invalid utf-8 with -profile strict} -body {
encoding convertfrom -profile strict utf-8 "\x40\x80\x00\x00"
} -returnCodes 1 -result {unexpected byte sequence starting at index 1: '\x80'}
test encoding-24.26 {Parse valid utf-8 with -strict} -body {
encoding convertfrom -strict utf-8 "\xF1\x80\x80\x80"
test encoding-24.26 {Parse valid utf-8 with -profile strict} -body {
encoding convertfrom -profile strict utf-8 "\xF1\x80\x80\x80"
} -result \U40000
test encoding-24.27 {Parse invalid utf-8 with -strict} -body {
encoding convertfrom -strict utf-8 "\xF0\x80\x80\x80"
test encoding-24.27 {Parse invalid utf-8 with -profile strict} -body {
encoding convertfrom -profile strict utf-8 "\xF0\x80\x80\x80"
} -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\xF0'}
test encoding-24.28 {Parse invalid utf-8 with -strict} -body {
encoding convertfrom -strict utf-8 "\xFF\x00\x00"
test encoding-24.28 {Parse invalid utf-8 with -profile strict} -body {
encoding convertfrom -profile strict utf-8 "\xFF\x00\x00"
} -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\xFF'}
test encoding-24.29 {Parse invalid utf-8} -body {
encoding convertfrom utf-8 \xEF\xBF\xBF
} -result \uFFFF
test encoding-24.30 {Parse noncharacter with -strict} -body {
encoding convertfrom -strict utf-8 \xEF\xBF\xBF
test encoding-24.30 {Parse noncharacter with -profile strict} -body {
encoding convertfrom -profile strict utf-8 \xEF\xBF\xBF
} -result \uFFFF
test encoding-24.31 {Parse invalid utf-8 with -nocomplain} -body {
encoding convertfrom -nocomplain utf-8 \xEF\xBF\xBF
test encoding-24.31 {Parse invalid utf-8 with -profile tcl8} -body {
encoding convertfrom -profile tcl8 utf-8 \xEF\xBF\xBF
} -result \uFFFF
test encoding-24.32 {Try to generate invalid utf-8} -body {
encoding convertto utf-8 \uFFFF
} -result \xEF\xBF\xBF
test encoding-24.33 {Try to generate noncharacter with -strict} -body {
encoding convertto -strict utf-8 \uFFFF
test encoding-24.33 {Try to generate noncharacter with -profile strict} -body {
encoding convertto -profile strict utf-8 \uFFFF
} -result \xEF\xBF\xBF
test encoding-24.34 {Try to generate invalid utf-8 with -nocomplain} -body {
encoding convertto -nocomplain utf-8 \uFFFF
test encoding-24.34 {Try to generate invalid utf-8 with -profile tcl8} -body {
encoding convertto -profile tcl8 utf-8 \uFFFF
} -result \xEF\xBF\xBF
test encoding-24.35 {Parse invalid utf-8} -constraints deprecated -body {
encoding convertfrom utf-8 \xED\xA0\x80
} -result \uD800
test encoding-24.36 {Parse invalid utf-8 with -strict} -body {
encoding convertfrom -strict utf-8 \xED\xA0\x80
test encoding-24.36 {Parse invalid utf-8 with -profile strict} -body {
encoding convertfrom -profile strict utf-8 \xED\xA0\x80
} -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\xED'}
test encoding-24.37 {Parse invalid utf-8 with -nocomplain} -body {
encoding convertfrom -nocomplain utf-8 \xED\xA0\x80
test encoding-24.37 {Parse invalid utf-8 with -profile tcl8} -body {
encoding convertfrom -profile tcl8 utf-8 \xED\xA0\x80
} -result \uD800
test encoding-24.38 {Try to generate invalid utf-8} -constraints deprecated -body {
encoding convertto utf-8 \uD800
} -result \xED\xA0\x80
test encoding-24.39 {Try to generate invalid utf-8 with -strict} -body {
encoding convertto -strict utf-8 \uD800
test encoding-24.39 {Try to generate invalid utf-8 with -profile strict} -body {
encoding convertto -profile strict utf-8 \uD800
} -returnCodes 1 -result {unexpected character at index 0: 'U+00D800'}
test encoding-24.40 {Try to generate invalid utf-8 with -nocomplain} -body {
encoding convertto -nocomplain utf-8 \uD800
test encoding-24.40 {Try to generate invalid utf-8 with -profile tcl8} -body {
encoding convertto -profile tcl8 utf-8 \uD800
} -result \xED\xA0\x80
test encoding-24.41 {Parse invalid utf-8 with -strict} -body {
encoding convertfrom -strict utf-8 \xED\xA0\x80\xED\xB0\x80
test encoding-24.41 {Parse invalid utf-8 with -profile strict} -body {
encoding convertfrom -profile strict utf-8 \xED\xA0\x80\xED\xB0\x80
} -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\xED'}
test encoding-24.42 {Parse invalid utf-8, fallback to cp1252 [885c86a9a0]} -body {
encoding convertfrom -nocomplain utf-8 \xF0\x80\x80\x80
encoding convertfrom -profile tcl8 utf-8 \xF0\x80\x80\x80
} -result \xF0\u20AC\u20AC\u20AC
test encoding-24.43 {Parse invalid utf-8, fallback to cp1252 [885c86a9a0]} -body {
encoding convertfrom -nocomplain utf-8 \x80
encoding convertfrom -profile tcl8 utf-8 \x80
} -result \u20AC
test encoding-24.44 {Try to generate invalid ucs-2 with -strict} -body {
encoding convertto -strict ucs-2 \uD800
test encoding-24.44 {Try to generate invalid ucs-2 with -profile strict} -body {
encoding convertto -profile strict ucs-2 \uD800
} -returnCodes 1 -result {unexpected character at index 0: 'U+00D800'}
test encoding-24.45 {Try to generate invalid ucs-2 with -strict} -body {
encoding convertto -strict ucs-2 \U10000
test encoding-24.45 {Try to generate invalid ucs-2 with -profile strict} -body {
encoding convertto -profile strict ucs-2 \U10000
} -returnCodes 1 -result {unexpected character at index 0: 'U+010000'}
file delete [file join [temporaryDirectory] iso2022.txt]
@@ -1021,7 +1021,7 @@ test encoding-28.0 {all encodings load} -body {
if {$name ne "unicode"} {
incr count
}
encoding convertto -nocomplain $name $string
encoding convertto -profile tcl8 $name $string
# discard the cached internal representation of Tcl_Encoding
# Unfortunately, without this, encoding 2-1 fails.
+26 -26
View File
@@ -272,7 +272,7 @@ test io-3.4 {WriteChars: loop over stage buffer} -body {
# stage buffer maps to more than can be queued at once.
set f [open $path(test1) w]
fconfigure $f -encoding jis0208 -buffersize 16 -nocomplainencoding 1
fconfigure $f -encoding jis0208 -buffersize 16 -profile tcl8
puts -nonewline $f "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"
set x [list [contents $path(test1)]]
close $f
@@ -286,7 +286,7 @@ test io-3.5 {WriteChars: saved != 0} -body {
# requested buffersize.
set f [open $path(test1) w]
fconfigure $f -encoding jis0208 -buffersize 17 -nocomplainencoding 1
fconfigure $f -encoding jis0208 -buffersize 17 -profile tcl8
puts -nonewline $f "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"
set x [list [contents $path(test1)]]
close $f
@@ -319,7 +319,7 @@ test io-3.7 {WriteChars: (bufPtr->nextAdded > bufPtr->length)} -body {
# of the next channel buffer.
set f [open $path(test1) w]
fconfigure $f -encoding jis0208 -buffersize 17 -nocomplainencoding 1
fconfigure $f -encoding jis0208 -buffersize 17 -profile tcl8
puts -nonewline $f "\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"
set x [list [contents $path(test1)]]
close $f
@@ -7622,7 +7622,7 @@ test io-52.20 {TclCopyChannel & encodings} -setup {
set out [open $path(kyrillic.txt) w]
# Using "-encoding ascii" means reading the "Á" gives an error
fconfigure $in -encoding ascii -strictencoding 1
fconfigure $in -encoding ascii -profile strict
fconfigure $out -encoding koi8-r -translation lf
fcopy $in $out
@@ -7644,7 +7644,7 @@ test io-52.21 {TclCopyChannel & encodings} -setup {
# Using "-encoding ascii" means writing the "Á" gives an error
fconfigure $in -encoding utf-8
fconfigure $out -encoding ascii -translation lf -strictencoding 1
fconfigure $out -encoding ascii -translation lf -profile strict
fcopy $in $out
} -cleanup {
@@ -7664,7 +7664,7 @@ test io-52.22 {TclCopyChannel & encodings} -setup {
set out [open $path(kyrillic.txt) w]
# Using "-encoding ascii" means reading the "Á" gives an error
fconfigure $in -encoding ascii -strictencoding 1
fconfigure $in -encoding ascii -profile strict
fconfigure $out -encoding koi8-r -translation lf
proc ::xxx args {
set ::s0 $args
@@ -7692,7 +7692,7 @@ test io-52.23 {TclCopyChannel & encodings} -setup {
# Using "-encoding ascii" means writing the "Á" gives an error
fconfigure $in -encoding utf-8
fconfigure $out -encoding ascii -translation lf -strictencoding 1
fconfigure $out -encoding ascii -translation lf -profile strict
proc ::xxx args {
set ::s0 $args
}
@@ -9061,7 +9061,7 @@ test io-75.1 {multibyte encoding error read results in raw bytes} -setup {
puts -nonewline $f A\xC0\x40
flush $f
seek $f 0
fconfigure $f -encoding utf-8 -nocomplainencoding 1 -buffering none
fconfigure $f -encoding utf-8 -profile tcl8 -buffering none
} -body {
set d [read $f]
binary scan $d H* hd
@@ -9071,10 +9071,10 @@ test io-75.1 {multibyte encoding error read results in raw bytes} -setup {
removeFile io-75.1
} -result 41c040
test io-75.2 {unrepresentable character write passes and is replaced by ? (-nocomplainencoding 1)} -setup {
test io-75.2 {unrepresentable character write passes and is replaced by ? (-profile tcl8)} -setup {
set fn [makeFile {} io-75.2]
set f [open $fn w+]
fconfigure $f -encoding iso8859-1 -nocomplainencoding 1
fconfigure $f -encoding iso8859-1 -profile tcl8
} -body {
puts -nonewline $f A\u2022
flush $f
@@ -9088,14 +9088,14 @@ test io-75.2 {unrepresentable character write passes and is replaced by ? (-noco
# Incomplete sequence test.
# This error may IMHO only be detected with the close.
# But the read already returns the incomplete sequence.
test io-75.3 {incomplete multibyte encoding read is ignored (-nocomplainencoding 1)} -setup {
test io-75.3 {incomplete multibyte encoding read is ignored (-profile tcl8)} -setup {
set fn [makeFile {} io-75.3]
set f [open $fn w+]
fconfigure $f -encoding binary
puts -nonewline $f "A\xC0"
flush $f
seek $f 0
fconfigure $f -encoding utf-8 -buffering none -nocomplainencoding 1
fconfigure $f -encoding utf-8 -buffering none -profile tcl8
} -body {
set d [read $f]
close $f
@@ -9107,7 +9107,7 @@ test io-75.3 {incomplete multibyte encoding read is ignored (-nocomplainencoding
# As utf-8 has a special treatment in multi-byte decoding, also test another
# one.
test io-75.4 {shiftjis encoding error read results in raw bytes (-nocomplainencoding 1)} -setup {
test io-75.4 {shiftjis encoding error read results in raw bytes (-profile tcl8)} -setup {
set fn [makeFile {} io-75.4]
set f [open $fn w+]
fconfigure $f -encoding binary
@@ -9116,7 +9116,7 @@ test io-75.4 {shiftjis encoding error read results in raw bytes (-nocomplainenco
puts -nonewline $f A\x81\xFFA
flush $f
seek $f 0
fconfigure $f -encoding shiftjis -buffering none -eofchar "" -translation lf -nocomplainencoding 1
fconfigure $f -encoding shiftjis -buffering none -eofchar "" -translation lf -profile tcl8
} -body {
set d [read $f]
binary scan $d H* hd
@@ -9126,14 +9126,14 @@ test io-75.4 {shiftjis encoding error read results in raw bytes (-nocomplainenco
removeFile io-75.4
} -result 4181ff41
test io-75.5 {invalid utf-8 encoding read is ignored (-nocomplainencoding 1)} -setup {
test io-75.5 {invalid utf-8 encoding read is ignored (-profile tcl8)} -setup {
set fn [makeFile {} io-75.5]
set f [open $fn w+]
fconfigure $f -encoding binary
puts -nonewline $f A\x81
flush $f
seek $f 0
fconfigure $f -encoding utf-8 -buffering none -eofchar "" -translation lf -nocomplainencoding 1
fconfigure $f -encoding utf-8 -buffering none -eofchar "" -translation lf -profile tcl8
} -body {
set d [read $f]
close $f
@@ -9143,7 +9143,7 @@ test io-75.5 {invalid utf-8 encoding read is ignored (-nocomplainencoding 1)} -s
removeFile io-75.5
} -result 4181
test io-75.6 {invalid utf-8 encoding read is not ignored (-strictencoding 1)} -setup {
test io-75.6 {invalid utf-8 encoding read is not ignored (-profile strict)} -setup {
set fn [makeFile {} io-75.6]
set f [open $fn w+]
fconfigure $f -encoding binary
@@ -9151,7 +9151,7 @@ test io-75.6 {invalid utf-8 encoding read is not ignored (-strictencoding 1)} -s
puts -nonewline $f A\x81
flush $f
seek $f 0
fconfigure $f -encoding utf-8 -buffering none -eofchar "" -translation lf -strictencoding 1
fconfigure $f -encoding utf-8 -buffering none -eofchar "" -translation lf -profile strict
} -body {
set d [read $f]
binary scan $d H* hd
@@ -9162,7 +9162,7 @@ test io-75.6 {invalid utf-8 encoding read is not ignored (-strictencoding 1)} -s
removeFile io-75.6
} -match glob -result {41 1 {error reading "*": illegal byte sequence}}
test io-75.7 {invalid utf-8 encoding eof handling (-strictencoding 1)} -setup {
test io-75.7 {invalid utf-8 encoding eof handling (-profile strict)} -setup {
set fn [makeFile {} io-75.7]
set f [open $fn w+]
fconfigure $f -encoding binary
@@ -9170,7 +9170,7 @@ test io-75.7 {invalid utf-8 encoding eof handling (-strictencoding 1)} -setup {
puts -nonewline $f A\xA1\x1A
flush $f
seek $f 0
fconfigure $f -encoding utf-8 -buffering none -eofchar \x1A -translation lf -strictencoding 1
fconfigure $f -encoding utf-8 -buffering none -eofchar \x1A -translation lf -profile strict
} -body {
set d [read $f]
binary scan $d H* hd
@@ -9185,7 +9185,7 @@ test io-75.7 {invalid utf-8 encoding eof handling (-strictencoding 1)} -setup {
removeFile io-75.7
} -match glob -result {41 0 1 {error reading "*": illegal byte sequence} ¡}
test io-75.8 {invalid utf-8 encoding eof handling (-strictencoding 1)} -setup {
test io-75.8 {invalid utf-8 encoding eof handling (-profile strict)} -setup {
set fn [makeFile {} io-75.8]
set f [open $fn w+]
fconfigure $f -encoding binary
@@ -9193,7 +9193,7 @@ test io-75.8 {invalid utf-8 encoding eof handling (-strictencoding 1)} -setup {
puts -nonewline $f A\x1A\x81
flush $f
seek $f 0
fconfigure $f -encoding utf-8 -buffering none -eofchar \x1A -translation lf -strictencoding 1
fconfigure $f -encoding utf-8 -buffering none -eofchar \x1A -translation lf -profile strict
} -body {
set d [read $f]
binary scan $d H* hd
@@ -9208,7 +9208,7 @@ test io-75.8 {invalid utf-8 encoding eof handling (-strictencoding 1)} -setup {
test io-75.9 {unrepresentable character write passes and is replaced by ?} -setup {
set fn [makeFile {} io-75.9]
set f [open $fn w+]
fconfigure $f -encoding iso8859-1 -strictencoding 1
fconfigure $f -encoding iso8859-1 -profile strict
} -body {
catch {puts -nonewline $f "A\u2022"} msg
flush $f
@@ -9252,7 +9252,7 @@ test io-75.11 {shiftjis encoding error read results in raw bytes} -setup {
puts -nonewline $f A\x81\xFFA
flush $f
seek $f 0
fconfigure $f -encoding shiftjis -buffering none -eofchar "" -translation lf -strictencoding 1
fconfigure $f -encoding shiftjis -buffering none -eofchar "" -translation lf -profile strict
} -body {
set d [read $f]
binary scan $d H* hd
@@ -9279,7 +9279,7 @@ test io-75.12 {invalid utf-8 encoding read is ignored} -setup {
} -cleanup {
removeFile io-75.12
} -result 4181
test io-75.13 {invalid utf-8 encoding read is not ignored (-strictencoding 1)} -setup {
test io-75.13 {invalid utf-8 encoding read is not ignored (-profile strict)} -setup {
set fn [makeFile {} io-75.13]
set f [open $fn w+]
fconfigure $f -encoding binary
@@ -9287,7 +9287,7 @@ test io-75.13 {invalid utf-8 encoding read is not ignored (-strictencoding 1)} -
puts -nonewline $f "A\x81"
flush $f
seek $f 0
fconfigure $f -encoding utf-8 -buffering none -eofchar "" -translation lf -strictencoding 1
fconfigure $f -encoding utf-8 -buffering none -eofchar "" -translation lf -profile strict
} -body {
set d [read $f]
binary scan $d H* hd
+14 -12
View File
@@ -207,7 +207,7 @@ test iocmd-7.5 {close command} -setup {
proc expectedOpts {got extra} {
set basicOpts {
-blocking -buffering -buffersize -encoding -eofchar -nocomplainencoding -strictencoding -translation
-blocking -buffering -buffersize -encoding -eofchar -profile -translation
}
set opts [list {*}$basicOpts {*}$extra]
lset opts end [string cat "or " [lindex $opts end]]
@@ -240,33 +240,33 @@ test iocmd-8.7 {fconfigure command} -setup {
file delete $path(test1)
} -body {
set f1 [open $path(test1) w]
fconfigure $f1 -translation lf -eofchar {} -encoding utf-16 -nocomplainencoding 1
fconfigure $f1 -translation lf -eofchar {} -encoding utf-16 -profile tcl8
fconfigure $f1
} -cleanup {
catch {close $f1}
} -result {-blocking 1 -buffering full -buffersize 4096 -encoding utf-16 -eofchar {} -nocomplainencoding 1 -strictencoding 0 -translation lf}
} -result {-blocking 1 -buffering full -buffersize 4096 -encoding utf-16 -eofchar {} -profile tcl8 -translation lf}
test iocmd-8.8 {fconfigure command} -setup {
file delete $path(test1)
set x {}
} -body {
set f1 [open $path(test1) w]
fconfigure $f1 -translation lf -buffering line -buffersize 3030 \
-eofchar {} -encoding utf-16 -nocomplainencoding 1
-eofchar {} -encoding utf-16 -profile tcl8
lappend x [fconfigure $f1 -buffering]
lappend x [fconfigure $f1]
} -cleanup {
catch {close $f1}
} -result {line {-blocking 1 -buffering line -buffersize 3030 -encoding utf-16 -eofchar {} -nocomplainencoding 1 -strictencoding 0 -translation lf}}
} -result {line {-blocking 1 -buffering line -buffersize 3030 -encoding utf-16 -eofchar {} -profile tcl8 -translation lf}}
test iocmd-8.9 {fconfigure command} -setup {
file delete $path(test1)
} -body {
set f1 [open $path(test1) w]
fconfigure $f1 -translation binary -buffering none -buffersize 4040 \
-eofchar {} -encoding binary -nocomplainencoding 1
-eofchar {} -encoding binary -profile tcl8
fconfigure $f1
} -cleanup {
catch {close $f1}
} -result {-blocking 1 -buffering none -buffersize 4040 -encoding binary -eofchar {} -nocomplainencoding 1 -strictencoding 0 -translation lf}
} -result {-blocking 1 -buffering none -buffersize 4040 -encoding binary -eofchar {} -profile tcl8 -translation lf}
test iocmd-8.10 {fconfigure command} -returnCodes error -body {
fconfigure a b
} -result {can not find channel named "a"}
@@ -369,7 +369,7 @@ test iocmd-8.20 {fconfigure command / win console channel} -constraints {nonPort
# TODO: Test parsing of serial channel options (nonPortable, since requires an
# open channel to work with).
test iocmd-8.21 {fconfigure command / -nocomplainencoding 0 error} -constraints {
deprecated
deprecated obsolete
} -setup {
# I don't know how else to open the console, but this is non-portable
set console stdin
@@ -378,7 +378,9 @@ test iocmd-8.21 {fconfigure command / -nocomplainencoding 0 error} -constraints
} -returnCodes error -result "bad value for -nocomplainencoding: only true allowed"
test iocmd-8.22 {fconfigure command / -nocomplainencoding 0, no error if -strictencoding already defined} -setup {
set console stdin
set oldmode [fconfigure $console -strictencoding]
set oldprofile [fconfigure $console -profile]
} -constraints {
obsolete
} -body {
fconfigure $console -strictencoding 1
fconfigure $console -nocomplainencoding 0
@@ -1381,7 +1383,7 @@ test iocmd-25.1 {chan configure, cgetall, standard options} -match glob -body {
close $c
rename foo {}
set res
} -result {{-blocking 1 -buffering full -buffersize 4096 -encoding * -eofchar {{} {}} -nocomplainencoding * -strictencoding 0 -translation {auto *}}}
} -result {{-blocking 1 -buffering full -buffersize 4096 -encoding * -eofchar {{} {}} -profile * -translation {auto *}}}
test iocmd-25.2 {chan configure, cgetall, no options} -match glob -body {
set res {}
proc foo {args} {oninit cget cgetall; onfinal; track; return ""}
@@ -1390,7 +1392,7 @@ test iocmd-25.2 {chan configure, cgetall, no options} -match glob -body {
close $c
rename foo {}
set res
} -result {{cgetall rc*} {-blocking 1 -buffering full -buffersize 4096 -encoding * -eofchar {{} {}} -nocomplainencoding * -strictencoding 0 -translation {auto *}}}
} -result {{cgetall rc*} {-blocking 1 -buffering full -buffersize 4096 -encoding * -eofchar {{} {}} -profile * -translation {auto *}}}
test iocmd-25.3 {chan configure, cgetall, regular result} -match glob -body {
set res {}
proc foo {args} {
@@ -1402,7 +1404,7 @@ test iocmd-25.3 {chan configure, cgetall, regular result} -match glob -body {
close $c
rename foo {}
set res
} -result {{cgetall rc*} {-blocking 1 -buffering full -buffersize 4096 -encoding * -eofchar {{} {}} -nocomplainencoding * -strictencoding 0 -translation {auto *} -bar foo -snarf x}}
} -result {{cgetall rc*} {-blocking 1 -buffering full -buffersize 4096 -encoding * -eofchar {{} {}} -profile * -translation {auto *} -bar foo -snarf x}}
test iocmd-25.4 {chan configure, cgetall, bad result, list of uneven length} -match glob -body {
set res {}
proc foo {args} {
+4 -4
View File
@@ -1473,7 +1473,7 @@ test safe-11.7 {testing safe encoding} -setup {
interp eval $i encoding convertfrom
} -returnCodes error -cleanup {
safe::interpDelete $i
} -result {wrong # args: should be "encoding convertfrom ?-strict? ?-failindex var? ?encoding? data" or "encoding convertfrom -nocomplain ?encoding? data"}
} -result {wrong # args: should be "encoding convertfrom ?-profile profile? ?-failindex var? encoding data" or "encoding convertfrom data"}
test safe-11.7.1 {testing safe encoding} -setup {
set i [safe::interpCreate]
} -body {
@@ -1482,7 +1482,7 @@ test safe-11.7.1 {testing safe encoding} -setup {
} -match glob -cleanup {
unset -nocomplain m o
safe::interpDelete $i
} -result {wrong # args: should be "encoding convertfrom ?-strict? ?-failindex var? ?encoding? data" or "encoding convertfrom -nocomplain ?encoding? data"
} -result {wrong # args: should be "encoding convertfrom ?-profile profile? ?-failindex var? encoding data" or "encoding convertfrom data"
while executing
"encoding convertfrom"
invoked from within
@@ -1495,7 +1495,7 @@ test safe-11.8 {testing safe encoding} -setup {
interp eval $i encoding convertto
} -returnCodes error -cleanup {
safe::interpDelete $i
} -result {wrong # args: should be "encoding convertto ?-strict? ?-failindex var? ?encoding? data" or "encoding convertto -nocomplain ?encoding? data"}
} -result {wrong # args: should be "encoding convertto ?-profile profile? ?-failindex var? encoding data" or "encoding convertto data"}
test safe-11.8.1 {testing safe encoding} -setup {
set i [safe::interpCreate]
} -body {
@@ -1504,7 +1504,7 @@ test safe-11.8.1 {testing safe encoding} -setup {
} -match glob -cleanup {
unset -nocomplain m o
safe::interpDelete $i
} -result {wrong # args: should be "encoding convertto ?-strict? ?-failindex var? ?encoding? data" or "encoding convertto -nocomplain ?encoding? data"
} -result {wrong # args: should be "encoding convertto ?-profile profile? ?-failindex var? encoding data" or "encoding convertto data"
while executing
"encoding convertto"
invoked from within
+1 -1
View File
@@ -1071,7 +1071,7 @@ test socket_$af-7.3 {testing socket specific options} -constraints [list socket
close $s
update
llength $l
} -result 22
} -result 20
test socket_$af-7.4 {testing socket specific options} -constraints [list socket supported_$af] -setup {
set timer [after 10000 "set x timed_out"]
set l ""
+7 -7
View File
@@ -198,7 +198,7 @@ test console-fconfigure-get-1.0 {
Console get stdin configuration
} -constraints {win interactive} -body {
lsort [dict keys [fconfigure stdin]]
} -result {-blocking -buffering -buffersize -encoding -eofchar -inputmode -translation}
} -result {-blocking -buffering -buffersize -encoding -profile -eofchar -inputmode -translation}
set testnum 0
foreach {opt result} {
@@ -224,7 +224,7 @@ test console-fconfigure-get-1.[incr testnum] {
fconfigure -winsize
} -constraints {win interactive} -body {
fconfigure stdin -winsize
} -result {bad option "-winsize": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -nocomplainencoding, -strictencoding, -translation, or -inputmode} -returnCodes error
} -result {bad option "-winsize": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -profile, -translation, or -inputmode} -returnCodes error
## fconfigure get stdout/stderr
foreach chan {stdout stderr} major {2 3} {
@@ -232,7 +232,7 @@ foreach chan {stdout stderr} major {2 3} {
win interactive
} -body {
lsort [dict keys [fconfigure $chan]]
} -result {-blocking -buffering -buffersize -encoding -eofchar -translation -winsize}
} -result {-blocking -buffering -buffersize -encoding -profile -eofchar -translation -winsize}
set testnum 0
foreach {opt result} {
-blocking 1
@@ -260,7 +260,7 @@ foreach chan {stdout stderr} major {2 3} {
fconfigure -inputmode
} -constraints {win interactive} -body {
fconfigure $chan -inputmode
} -result {bad option "-inputmode": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -nocomplainencoding, -strictencoding, -translation, or -winsize} -returnCodes error
} -result {bad option "-inputmode": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -profile, -translation, or -winsize} -returnCodes error
}
@@ -330,7 +330,7 @@ test console-fconfigure-set-1.3 {
fconfigure stdin -winsize
} -constraints {win interactive} -body {
fconfigure stdin -winsize {10 30}
} -result {bad option "-winsize": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -nocomplainencoding, -strictencoding, -translation, or -inputmode} -returnCodes error
} -result {bad option "-winsize": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -profile, -translation, or -inputmode} -returnCodes error
## fconfigure set stdout,stderr
@@ -338,13 +338,13 @@ test console-fconfigure-set-2.0 {
fconfigure stdout -winsize
} -constraints {win interactive} -body {
fconfigure stdout -winsize {10 30}
} -result {bad option "-winsize": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -nocomplainencoding, -strictencoding, or -translation} -returnCodes error
} -result {bad option "-winsize": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -profile, or -translation} -returnCodes error
test console-fconfigure-set-3.0 {
fconfigure stderr -winsize
} -constraints {win interactive} -body {
fconfigure stderr -winsize {10 30}
} -result {bad option "-winsize": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -nocomplainencoding, -strictencoding, or -translation} -returnCodes error
} -result {bad option "-winsize": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, -profile, or -translation} -returnCodes error
# Multiple threads
+4 -2
View File
@@ -15,6 +15,8 @@ if {"::tcltest" ni [namespace children]} {
namespace import -force ::tcltest::*
}
source [file join [file dirname [info script]] tcltests.tcl]
testConstraint zlib [llength [info commands zlib]]
testConstraint recentZlib 0
catch {
@@ -292,7 +294,7 @@ test zlib-8.6 {transformation and fconfigure} -setup {
} -cleanup {
catch {close $fd}
removeFile $file
} -result {{-blocking 1 -buffering full -buffersize 4096 -encoding binary -eofchar {} -nocomplainencoding 1 -strictencoding 0 -translation lf} {-blocking 1 -buffering full -buffersize 4096 -encoding binary -eofchar {} -nocomplainencoding 1 -strictencoding 0 -translation lf -checksum 1 -dictionary {}} {-blocking 1 -buffering full -buffersize 4096 -encoding binary -eofchar {} -nocomplainencoding 1 -strictencoding 0 -translation lf}}
} -result {{-blocking 1 -buffering full -buffersize 4096 -encoding binary -eofchar {} -profile tcl8 -translation lf} {-blocking 1 -buffering full -buffersize 4096 -encoding binary -eofchar {} -profile tcl8 -translation lf -checksum 1 -dictionary {}} {-blocking 1 -buffering full -buffersize 4096 -encoding binary -eofchar {} -profile tcl8 -translation lf}}
test zlib-8.7 {transformation and fconfigure} -setup {
set file [makeFile {} test.gz]
set fd [open $file wb]
@@ -302,7 +304,7 @@ test zlib-8.7 {transformation and fconfigure} -setup {
} -cleanup {
catch {close $fd}
removeFile $file
} -result {{-blocking 1 -buffering full -buffersize 4096 -encoding binary -eofchar {} -nocomplainencoding 1 -strictencoding 0 -translation lf} {-blocking 1 -buffering full -buffersize 4096 -encoding binary -eofchar {} -nocomplainencoding 1 -strictencoding 0 -translation lf -checksum 0} {-blocking 1 -buffering full -buffersize 4096 -encoding binary -eofchar {} -nocomplainencoding 1 -strictencoding 0 -translation lf}}
} -result {{-blocking 1 -buffering full -buffersize 4096 -encoding binary -eofchar {} -profile tcl8 -translation lf} {-blocking 1 -buffering full -buffersize 4096 -encoding binary -eofchar {} -profile tcl8 -translation lf -checksum 0} {-blocking 1 -buffering full -buffersize 4096 -encoding binary -eofchar {} -profile tcl8 -translation lf}}
# Input is headers from fetching SPDY draft
# Dictionary is that which is proposed _in_ SPDY draft
set spdyHeaders "HTTP/1.0 200 OK\r\nContent-Type: text/html; charset=utf-8\r\nX-Robots-Tag: noarchive\r\nLast-Modified: Tue, 05 Jun 2012 02:43:25 GMT\r\nETag: \"1338864205129|#public|0|en|||0\"\r\nExpires: Tue, 05 Jun 2012 16:17:11 GMT\r\nDate: Tue, 05 Jun 2012 16:17:06 GMT\r\nCache-Control: public, max-age=5\r\nX-Content-Type-Options: nosniff\r\nX-XSS-Protection: 1; mode=block\r\nServer: GSE\r\n"