tal_string-was-coded-wrong-from-the-start-20031209
authorJeffrey Altman <jaltman@grand.central.org>
Wed, 10 Dec 2003 08:01:35 +0000 (08:01 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 10 Dec 2003 08:01:35 +0000 (08:01 +0000)
tal_string defines three types: String, Ansi, Unicode
and provides functions to convert between them.  The
initial problem with this module was a lack of consistent
memory allocation.  The secondary problem was incorrect
conversion of between string types.

src/WINNT/talocale/tal_string.cpp

index c30573c..b1bb833 100644 (file)
@@ -1530,13 +1530,12 @@ LPWSTR StringToUnicode (LPCTSTR pszOriginal)
     int len = lstrlen(pszOriginal);
     if ((pszTargetW = AllocateUnicode (1+len)) != NULL) {
 #ifdef UNICODE
-        CopyAnsiToUnicode (pszTargetW, pszOriginal);
+        lstrcpyW ((LPWSTR)pszTargetW, (LPWSTR)pszOriginal);
 #else
-        lstrcpy ((LPSTR)pszTargetW, (LPSTR)pszOriginal);
+        CopyAnsiToUnicode (pszTargetW, pszOriginal);
 #endif
     }
     return pszTargetW;
-#endif
 }
 
 LPTSTR UnicodeToString (LPCWSTR pszOriginalW)
@@ -1546,13 +1545,12 @@ LPTSTR UnicodeToString (LPCWSTR pszOriginalW)
     LPTSTR pszTarget;
     if ((pszTarget = AllocateString (1+lstrlenW(pszOriginalW))) != NULL) {
 #ifdef UNICODE
-        CopyUnicodeToAnsi (pszTarget, pszOriginalW);
+        lstrcpyW ((LPWSTR)pszTargetW, (LPWSTR)pszOriginal);
 #else
-        lstrcpyA ((LPSTR)pszTarget, pszOriginalW);
+        CopyUnicodeToAnsi (pszTarget, pszOriginalW);
 #endif
     }
     return pszTarget;
-#endif
 }