summaryrefslogtreecommitdiff
path: root/asdcplib/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-11-26 09:58:48 +0000
committerCarl Hetherington <cth@carlh.net>2013-11-26 09:58:48 +0000
commitaaa8fe37ec65ed9db6952d9424bbe0e892fe4dd4 (patch)
treec247116b54c7336323a62d8ef4593991808968c2 /asdcplib/src
parent66ea991028e62daf8bae5b6f1ad348c3eabe1da8 (diff)
Try to fix incorrect non-Latin handling on Win32 filenames.
Diffstat (limited to 'asdcplib/src')
-rw-r--r--asdcplib/src/KM_fileio.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/asdcplib/src/KM_fileio.cpp b/asdcplib/src/KM_fileio.cpp
index df2eb974..78e394a6 100644
--- a/asdcplib/src/KM_fileio.cpp
+++ b/asdcplib/src/KM_fileio.cpp
@@ -689,8 +689,10 @@ Kumu::FileReader::OpenRead(const char* filename) const
// suppress popup window on error
UINT prev = ::SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
- wchar_t buffer[1024];
- if (MultiByteToWideChar (CP_UTF8, MB_PRECOMPOSED, filename, -1, buffer, 1024)) {
+ int const wn = MultiByteToWideChar (CP_UTF8, 0, filename, -1, 0, 0);
+ whar_t* buffer = new wchar_t[wn];
+ if (MultiByteToWideChar (CP_UTF8, 0, filename, -1, buffer, wn)) {
+ delete[] buffer;
return Kumu::RESULT_FAIL;
}
@@ -703,6 +705,8 @@ Kumu::FileReader::OpenRead(const char* filename) const
NULL // no template file
);
+ delete[] buffer;
+
::SetErrorMode(prev);
return ( m_Handle == INVALID_HANDLE_VALUE ) ?
@@ -819,8 +823,10 @@ Kumu::FileWriter::OpenWrite(const char* filename)
// suppress popup window on error
UINT prev = ::SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
- wchar_t buffer[1024];
- if (MultiByteToWideChar (CP_UTF8, MB_PRECOMPOSED, filename, -1, buffer, 1024)) {
+ int const wn = MultiByteToWideChar (CP_UTF8, 0, filename, -1, 0, 0);
+ whar_t* buffer = new wchar_t[wn];
+ if (MultiByteToWideChar (CP_UTF8, 0, filename, -1, buffer, wn)) {
+ delete[] buffer;
return Kumu::RESULT_FAIL;
}
@@ -833,6 +839,8 @@ Kumu::FileWriter::OpenWrite(const char* filename)
NULL // no template file
);
+ delete[] buffer;
+
::SetErrorMode(prev);
if ( m_Handle == INVALID_HANDLE_VALUE )
@@ -852,8 +860,10 @@ Kumu::FileWriter::OpenModify(const char* filename)
// suppress popup window on error
UINT prev = ::SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
- wchar_t buffer[1024];
- if (MultiByteToWideChar (CP_UTF8, MB_PRECOMPOSED, filename, -1, buffer, 1024)) {
+ int const wn = MultiByteToWideChar (CP_UTF8, 0, filename, -1, 0, 0);
+ whar_t* buffer = new wchar_t[wn];
+ if (MultiByteToWideChar (CP_UTF8, 0, filename, -1, buffer, wn)) {
+ delete[] buffer;
return Kumu::RESULT_FAIL;
}
@@ -866,6 +876,8 @@ Kumu::FileWriter::OpenModify(const char* filename)
NULL // no template file
);
+ delete[] buffer;
+
::SetErrorMode(prev);
if ( m_Handle == INVALID_HANDLE_VALUE )