summaryrefslogtreecommitdiffstats
path: root/generic/tclUtil.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclUtil.c')
-rw-r--r--generic/tclUtil.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index c73841f..66dd9ea 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -4325,6 +4325,7 @@ TclSetProcessGlobalValue(
Tcl_HashTable *cacheMap;
Tcl_HashEntry *hPtr;
int dummy;
+ Tcl_DString ds;
Tcl_MutexLock(&pgvPtr->mutex);
@@ -4340,8 +4341,11 @@ TclSetProcessGlobalValue(
}
bytes = TclGetString(newValue);
pgvPtr->numBytes = newValue->length;
+ Tcl_UtfToExternalDString(encoding, bytes, pgvPtr->numBytes, &ds);
+ pgvPtr->numBytes = Tcl_DStringLength(&ds);
pgvPtr->value = (char *)ckalloc(pgvPtr->numBytes + 1);
- memcpy(pgvPtr->value, bytes, pgvPtr->numBytes + 1);
+ memcpy(pgvPtr->value, Tcl_DStringValue(&ds), pgvPtr->numBytes + 1);
+ Tcl_DStringFree(&ds);
if (pgvPtr->encoding) {
Tcl_FreeEncoding(pgvPtr->encoding);
}
@@ -4383,6 +4387,7 @@ TclGetProcessGlobalValue(
Tcl_HashTable *cacheMap;
Tcl_HashEntry *hPtr;
Tcl_Size epoch = pgvPtr->epoch;
+ Tcl_DString newValue;
if (pgvPtr->encoding) {
Tcl_Encoding current = Tcl_GetEncoding(NULL, NULL);
@@ -4394,7 +4399,7 @@ TclGetProcessGlobalValue(
* system encoding.
*/
- Tcl_DString native, newValue;
+ Tcl_DString native;
Tcl_MutexLock(&pgvPtr->mutex);
epoch = ++pgvPtr->epoch;
@@ -4444,10 +4449,13 @@ TclGetProcessGlobalValue(
}
/*
- * Store a copy of the shared value in our epoch-indexed cache.
+ * Store a copy of the shared value (but then in utf-8)
+ * in our epoch-indexed cache.
*/
- value = Tcl_NewStringObj(pgvPtr->value, pgvPtr->numBytes);
+ Tcl_ExternalToUtfDString(NULL, pgvPtr->value, pgvPtr->numBytes, &newValue);
+ value = Tcl_NewStringObj(Tcl_DStringValue(&newValue), Tcl_DStringLength(&newValue));
+ Tcl_DStringFree(&newValue);
hPtr = Tcl_CreateHashEntry(cacheMap,
INT2PTR(pgvPtr->epoch), &dummy);
Tcl_MutexUnlock(&pgvPtr->mutex);