summaryrefslogtreecommitdiffstats
path: root/generic/tkOption.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tkOption.c')
-rw-r--r--generic/tkOption.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/generic/tkOption.c b/generic/tkOption.c
index 91a6cc0..bff799b 100644
--- a/generic/tkOption.c
+++ b/generic/tkOption.c
@@ -1086,7 +1086,7 @@ ReadOptionFile(
char *buffer;
int result, bufferSize;
Tcl_Channel chan;
- Tcl_DString newName;
+ Tcl_DString newName, optString;
/*
* Prevent file system access in a safe interpreter.
@@ -1136,7 +1136,16 @@ ReadOptionFile(
}
Tcl_Close(NULL, chan);
buffer[bufferSize] = 0;
- result = AddFromString(interp, tkwin, buffer, priority);
+ if ((bufferSize>2) && !memcmp(buffer, "\357\273\277", 3)) {
+ /* File starts with UTF-8 BOM */
+ result = AddFromString(interp, tkwin, buffer+3, priority);
+ } else {
+ Tcl_DStringInit(&optString);
+ Tcl_ExternalToUtfDString(NULL, buffer, bufferSize, &optString);
+ result = AddFromString(interp, tkwin, Tcl_DStringValue(&optString),
+ priority);
+ Tcl_DStringFree(&optString);
+ }
ckfree(buffer);
return result;
}