summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2023-09-13 11:00:46 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2023-09-13 11:00:46 (GMT)
commit56f7295088b9f0d9f2d1a0097683eda55701b5dd (patch)
treec8d102b5ecad932593842ceaa7f77a5b5e1daa1c
parent6d1fc5cfd9adab08343ce1aecf5a26e79becbcc2 (diff)
downloadtcl-56f7295088b9f0d9f2d1a0097683eda55701b5dd.zip
tcl-56f7295088b9f0d9f2d1a0097683eda55701b5dd.tar.gz
tcl-56f7295088b9f0d9f2d1a0097683eda55701b5dd.tar.bz2
Fix [43b0656605]: MS Windows: files with emojis are found by glob but not recognized by file exists or open
-rw-r--r--win/tclWinFile.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/win/tclWinFile.c b/win/tclWinFile.c
index 3b1ff76..9f4e857 100644
--- a/win/tclWinFile.c
+++ b/win/tclWinFile.c
@@ -3032,8 +3032,10 @@ TclNativeCreateNativeRep(
WCHAR *nativePathPtr = NULL;
const char *str;
Tcl_Obj *validPathPtr;
- size_t len;
+ int len;
WCHAR *wp;
+ Tcl_DString ds;
+ Tcl_Encoding utf8;
if (TclFSCwdIsNative()) {
/*
@@ -3069,10 +3071,13 @@ TclNativeCreateNativeRep(
Tcl_IncrRefCount(validPathPtr);
}
- str = Tcl_GetString(validPathPtr);
- len = validPathPtr->length;
+ utf8 = Tcl_GetEncoding(NULL, "utf-8");
+ str = Tcl_GetStringFromObj(validPathPtr, &len);
+ str = Tcl_UtfToExternalDString(utf8, str, len, &ds);
+ len = Tcl_DStringLength(&ds);
+ Tcl_FreeEncoding(utf8);
- if (strlen(str) != len) {
+ if (strlen(str) != (size_t)len) {
/*
* String contains NUL-bytes. This is invalid.
*/
@@ -3166,6 +3171,7 @@ TclNativeCreateNativeRep(
}
done:
+ Tcl_DStringFree(&ds);
TclDecrRefCount(validPathPtr);
return nativePathPtr;
}