aboutsummaryrefslogtreecommitdiff
path: root/src/SBaseCommon.cpp
diff options
context:
space:
mode:
authorLadislav Zezula <zezula@volny.cz>2024-03-07 17:46:27 +0100
committerLadislav Zezula <zezula@volny.cz>2024-03-07 17:46:27 +0100
commitdbe502676f27ac8510a52ff7b3ab8e03e81179fe (patch)
treedf23ed9d3cd804ab40e6c9c20c3698b3938dc834 /src/SBaseCommon.cpp
parent98aff2cdec461c77688ef4e954e492e6c04ae34e (diff)
+ Fixed regression tests
+ Refactored udage of UNICODE characters + Fixed regression tests on Linux
Diffstat (limited to 'src/SBaseCommon.cpp')
-rw-r--r--src/SBaseCommon.cpp36
1 files changed, 18 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
//-----------------------------------------------------------------------------