summaryrefslogtreecommitdiffstats
path: root/Source/JavaScriptCore/jsc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/jsc.cpp')
-rw-r--r--Source/JavaScriptCore/jsc.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/Source/JavaScriptCore/jsc.cpp b/Source/JavaScriptCore/jsc.cpp
index d9f888fb1..c0a84fc5f 100644
--- a/Source/JavaScriptCore/jsc.cpp
+++ b/Source/JavaScriptCore/jsc.cpp
@@ -68,6 +68,7 @@
#if OS(WINDOWS)
#include <direct.h>
+#include <wtf/text/win/WCharStringExtras.h>
#else
#include <unistd.h>
#endif
@@ -868,8 +869,7 @@ static bool currentWorkingDirectory(DirectoryName& directoryName)
// https://msdn.microsoft.com/en-us/library/windows/desktop/ff381407.aspx
auto buffer = std::make_unique<wchar_t[]>(bufferLength);
DWORD lengthNotIncludingNull = ::GetCurrentDirectoryW(bufferLength, buffer.get());
- static_assert(sizeof(wchar_t) == sizeof(UChar), "In Windows, both are UTF-16LE");
- String directoryString = String(reinterpret_cast<UChar*>(buffer.get()));
+ String directoryString = wcharToString(buffer.get(), lengthNotIncludingNull);
// We don't support network path like \\host\share\<path name>.
if (directoryString.startsWith("\\\\"))
return false;
@@ -999,9 +999,7 @@ static bool fetchModuleFromLocalFileSystem(const String& fileName, Vector<char>&
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247.aspx#maxpath
// Use long UNC to pass the long path name to the Windows APIs.
String longUNCPathName = WTF::makeString("\\\\?\\", fileName);
- static_assert(sizeof(wchar_t) == sizeof(UChar), "In Windows, both are UTF-16LE");
- auto utf16Vector = longUNCPathName.charactersWithNullTermination();
- FILE* f = _wfopen(reinterpret_cast<wchar_t*>(utf16Vector.data()), L"rb");
+ FILE* f = _wfopen(stringToNullTerminatedWChar(longUNCPathName).data(), L"rb");
#else
FILE* f = fopen(fileName.utf8().data(), "r");
#endif