diff options
author | Ladislav Zezula <zezula@volny.cz> | 2024-03-07 17:46:27 +0100 |
---|---|---|
committer | Ladislav Zezula <zezula@volny.cz> | 2024-03-07 17:46:27 +0100 |
commit | dbe502676f27ac8510a52ff7b3ab8e03e81179fe (patch) | |
tree | df23ed9d3cd804ab40e6c9c20c3698b3938dc834 /src | |
parent | 98aff2cdec461c77688ef4e954e492e6c04ae34e (diff) |
+ Fixed regression tests
+ Refactored udage of UNICODE characters
+ Fixed regression tests on Linux
Diffstat (limited to 'src')
-rw-r--r-- | src/SBaseCommon.cpp | 36 | ||||
-rw-r--r-- | src/StormCommon.h | 1 |
2 files changed, 19 insertions, 18 deletions
diff --git a/src/SBaseCommon.cpp b/src/SBaseCommon.cpp index 7415583..587efe4 100644 --- a/src/SBaseCommon.cpp +++ b/src/SBaseCommon.cpp @@ -154,30 +154,18 @@ void StringCreatePseudoFileName(char * szBuffer, size_t cchMaxChars, unsigned in #ifdef _UNICODE
void StringCopy(TCHAR * szTarget, size_t cchTarget, const char * szSource)
{
- if(cchTarget > 0)
- {
- size_t cchSource = strlen(szSource);
+ int ccResult;
- if(cchSource >= cchTarget)
- cchSource = cchTarget - 1;
-
- mbstowcs(szTarget, szSource, cchSource);
- szTarget[cchSource] = 0;
- }
+ ccResult = MultiByteToWideChar(CP_UTF8, 0, szSource, -1, szTarget, (int)(cchTarget));
+ szTarget[ccResult] = 0;
}
void StringCopy(char * szTarget, size_t cchTarget, const TCHAR * szSource)
{
- if(cchTarget > 0)
- {
- size_t cchSource = _tcslen(szSource);
-
- if(cchSource >= cchTarget)
- cchSource = cchTarget - 1;
+ int ccResult;
- wcstombs(szTarget, szSource, cchSource);
- szTarget[cchSource] = 0;
- }
+ ccResult = WideCharToMultiByte(CP_UTF8, 0, szSource, -1, szTarget, (int)(cchTarget), NULL, NULL);
+ szTarget[ccResult] = 0;
}
void StringCopy(TCHAR * szTarget, size_t cchTarget, const TCHAR * szSource)
@@ -205,6 +193,18 @@ void StringCat(TCHAR * szTarget, size_t cchTargetMax, const TCHAR * szSource) StringCopy(szTarget + cchTarget, (cchTargetMax - cchTarget), szSource);
}
}
+
+void StringCat(TCHAR * szTarget, size_t cchTargetMax, const char * szSource)
+{
+ // Get the current length of the target
+ size_t cchTarget = _tcslen(szTarget);
+
+ // Copy the string to the target
+ if(cchTarget < cchTargetMax)
+ {
+ StringCopy(szTarget + cchTarget, (cchTargetMax - cchTarget), szSource);
+ }
+}
#endif
//-----------------------------------------------------------------------------
diff --git a/src/StormCommon.h b/src/StormCommon.h index c73543d..c050093 100644 --- a/src/StormCommon.h +++ b/src/StormCommon.h @@ -206,6 +206,7 @@ void StringCopy(TCHAR * szTarget, size_t cchTarget, const char * szSource); void StringCopy(char * szTarget, size_t cchTarget, const TCHAR * szSource);
void StringCopy(TCHAR * szTarget, size_t cchTarget, const TCHAR * szSource);
void StringCat(TCHAR * szTarget, size_t cchTargetMax, const TCHAR * szSource);
+void StringCat(TCHAR * szTarget, size_t cchTargetMax, const char * szSource);
#endif
//-----------------------------------------------------------------------------
|