[xmlsec] xmlsec-mscrypto: convert to unicode



commit c9ca27a91b418f7d2b9faee8db6cf7d0aad9c85c
Author: Aleksey Sanin <aleksey aleksey com>
Date:   Tue Apr 27 18:21:11 2010 -0700

    xmlsec-mscrypto: convert to unicode

 ChangeLog                        |    4 +
 include/xmlsec/mscrypto/app.h    |    2 +-
 include/xmlsec/mscrypto/crypto.h |    7 +-
 include/xmlsec/mscrypto/x509.h   |    8 +-
 src/mscrypto/app.c               |   29 ++++-
 src/mscrypto/crypto.c            |  252 ++++++++++++++++++++++++++++++++------
 src/mscrypto/csp_calg.h          |   16 ++-
 src/mscrypto/keysstore.c         |   16 ++-
 src/mscrypto/x509.c              |  102 ++++++++++------
 src/mscrypto/x509vfy.c           |  112 +++++++++++++----
 src/mscrypto/xmlsec-mingw.h      |    6 +-
 win32/Makefile.msvc              |    5 +
 win32/configure.js               |    6 +
 win32/mycfg.bat                  |    2 +-
 14 files changed, 450 insertions(+), 117 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b76e1ab..4292f8f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,8 @@
 2010-04-26  Aleksey Sanin  <aleksey aleksey com>
+	* Converted xmlsec-mscrypto to unicode and provided a compile time 
+	option to switch between unicode/non-unicode builds
+
+2010-04-26  Aleksey Sanin  <aleksey aleksey com>
 	* Added support for HMAC with MD5, SHA1, SHA256/384/512 in xmlsec-mscrypto
 	* Added support for MD5 RSA/MD5 in xmlsec-mscrypto
 
diff --git a/include/xmlsec/mscrypto/app.h b/include/xmlsec/mscrypto/app.h
index b7f09c9..7790208 100644
--- a/include/xmlsec/mscrypto/app.h
+++ b/include/xmlsec/mscrypto/app.h
@@ -26,7 +26,7 @@ extern "C" {
  */
 XMLSEC_CRYPTO_EXPORT int        xmlSecMSCryptoAppInit                           (const char* config);
 XMLSEC_CRYPTO_EXPORT int        xmlSecMSCryptoAppShutdown                       (void);
-XMLSEC_CRYPTO_EXPORT const char*xmlSecMSCryptoAppGetCertStoreName               (void);
+XMLSEC_CRYPTO_EXPORT LPCTSTR    xmlSecMSCryptoAppGetCertStoreName               (void);
 
 /**
  * Keys Manager
diff --git a/include/xmlsec/mscrypto/crypto.h b/include/xmlsec/mscrypto/crypto.h
index 1f8ea3a..e0caf9e 100644
--- a/include/xmlsec/mscrypto/crypto.h
+++ b/include/xmlsec/mscrypto/crypto.h
@@ -44,11 +44,16 @@ XMLSEC_CRYPTO_EXPORT void               xmlSecMSCryptoErrorsDefaultCallback(cons
 /**
  * Utils
  */
-XMLSEC_CRYPTO_EXPORT LPWSTR             xmlSecMSCryptoConvertUtf8ToUnicode  (const xmlChar* str);
 XMLSEC_CRYPTO_EXPORT LPWSTR             xmlSecMSCryptoConvertLocaleToUnicode(const char* str);
 
+XMLSEC_CRYPTO_EXPORT LPWSTR             xmlSecMSCryptoConvertUtf8ToUnicode  (const xmlChar* str);
 XMLSEC_CRYPTO_EXPORT xmlChar*           xmlSecMSCryptoConvertUnicodeToUtf8  (LPCWSTR str);
 
+XMLSEC_CRYPTO_EXPORT xmlChar*           xmlSecMSCryptoConvertLocaleToUtf8   (const char* str);
+XMLSEC_CRYPTO_EXPORT char*              xmlSecMSCryptoConvertUtf8ToLocale   (const xmlChar* str);
+
+XMLSEC_CRYPTO_EXPORT xmlChar*           xmlSecMSCryptoConvertTstrToUtf8   (LPCTSTR str);
+XMLSEC_CRYPTO_EXPORT LPTSTR             xmlSecMSCryptoConvertUtf8ToTstr   (const xmlChar*  str);
 
 /**
  * Crypto Providers
diff --git a/include/xmlsec/mscrypto/x509.h b/include/xmlsec/mscrypto/x509.h
index 46bc446..c8817f1 100644
--- a/include/xmlsec/mscrypto/x509.h
+++ b/include/xmlsec/mscrypto/x509.h
@@ -97,9 +97,15 @@ XMLSEC_CRYPTO_EXPORT void               xmlSecMSCryptoX509StoreEnableSystemTrust
  * Util functions
  */
 XMLSEC_CRYPTO_EXPORT PCCERT_CONTEXT     xmlSecMSCryptoX509FindCertBySubject     (HCERTSTORE store,
-                                                                                 const LPWSTR wcSubject,
+                                                                                 const LPTSTR wcSubject,
                                                                                  DWORD dwCertEncodingType);
 
+XMLSEC_CRYPTO_EXPORT xmlChar *          xmlSecMSCryptoX509GetNameString         (PCCERT_CONTEXT pCertContext,
+                                                                                 DWORD dwType,
+                                                                                 DWORD dwFlags,
+                                                                                 void *pvTypePara);
+
+
 #endif /* XMLSEC_NO_X509 */
 
 #ifdef __cplusplus
diff --git a/src/mscrypto/app.c b/src/mscrypto/app.c
index e6ef5ce..3db1554 100644
--- a/src/mscrypto/app.c
+++ b/src/mscrypto/app.c
@@ -33,7 +33,7 @@
 /* I don't see any other way then to use a global var to get the
  * config info to the mscrypto keysstore :(  WK
  */
-static char *gXmlSecMSCryptoAppCertStoreName = NULL;
+static LPTSTR gXmlSecMSCryptoAppCertStoreName = NULL;
 
 /**
  * xmlSecMSCryptoAppInit:
@@ -53,7 +53,7 @@ xmlSecMSCryptoAppInit(const char* config) {
      * then the default (MY)
      */
     if (NULL != config && strlen(config) > 0) {
-        if (gXmlSecMSCryptoAppCertStoreName) {
+        if (gXmlSecMSCryptoAppCertStoreName != NULL) {
             /* This should not happen, initialize twice */
             xmlSecError(XMLSEC_ERRORS_HERE,
                         NULL,
@@ -63,7 +63,30 @@ xmlSecMSCryptoAppInit(const char* config) {
                         xmlSecErrorsSafeString(config));
             return (-1);
         }
+
+#ifdef UNICODE
+        gXmlSecMSCryptoAppCertStoreName = xmlSecMSCryptoConvertLocaleToUnicode(config);
+        if (gXmlSecMSCryptoAppCertStoreName == NULL) {
+            xmlSecError(XMLSEC_ERRORS_HERE,
+                        "xmlSecMSCryptoConvertLocaleToUnicode",
+                        NULL,
+                        XMLSEC_ERRORS_R_MALLOC_FAILED,
+                        "config=%s",
+                        xmlSecErrorsSafeString(config));
+            return (-1);
+        }
+#else  /* UNICODE */
         gXmlSecMSCryptoAppCertStoreName = xmlStrdup(config);
+        if (gXmlSecMSCryptoAppCertStoreName == NULL) {
+            xmlSecError(XMLSEC_ERRORS_HERE,
+                        "xmlStrdup",
+                        NULL,
+                        XMLSEC_ERRORS_R_MALLOC_FAILED,
+                        "config=%s",
+                        xmlSecErrorsSafeString(config));
+            return (-1);
+        }
+#endif /* UNICODE */
     }
 
     return(0);
@@ -95,7 +118,7 @@ xmlSecMSCryptoAppShutdown(void) {
  *
  * Returns: the MS Crypto certs name used by xmlsec-mscrypto.
  */
-const char*
+LPCTSTR
 xmlSecMSCryptoAppGetCertStoreName(void) {
     return(gXmlSecMSCryptoAppCertStoreName);
 }
diff --git a/src/mscrypto/crypto.c b/src/mscrypto/crypto.c
index a9b3854..6176e32 100644
--- a/src/mscrypto/crypto.c
+++ b/src/mscrypto/crypto.c
@@ -28,7 +28,14 @@
 #  include "xmlsec-mingw.h"
 #endif
 
-#define XMLSEC_CONTAINER_NAME "xmlsec-key-container"
+#define XMLSEC_CONTAINER_NAME_A "xmlsec-key-container"
+#define XMLSEC_CONTAINER_NAME_W L"xmlsec-key-container"
+#ifdef UNICODE
+#define XMLSEC_CONTAINER_NAME XMLSEC_CONTAINER_NAME_W
+#else
+#define XMLSEC_CONTAINER_NAME XMLSEC_CONTAINER_NAME_A
+#endif
+
 
 static xmlSecCryptoDLFunctionsPtr gXmlSecMSCryptoFunctions = NULL;
 
@@ -363,6 +370,8 @@ xmlSecMSCryptoGenerateRandom(xmlSecBufferPtr buffer, size_t size) {
     return(0);
 }
 
+#define XMLSEC_MSCRYPTO_ERROR_MSG_BUFFER_SIZE       4096
+
 /**
  * xmlSecMSCryptoErrorsDefaultCallback:
  * @file:               the error location file name (__FILE__ macro).
@@ -380,29 +389,52 @@ xmlSecMSCryptoErrorsDefaultCallback(const char* file, int line, const char* func
                                 const char* errorObject, const char* errorSubject,
                                 int reason, const char* msg) {
     DWORD dwError;
-    LPVOID lpMsgBuf;
-    xmlChar buf[500];
+    TCHAR errorT[XMLSEC_MSCRYPTO_ERROR_MSG_BUFFER_SIZE];
+    WCHAR errorW[XMLSEC_MSCRYPTO_ERROR_MSG_BUFFER_SIZE];
+    CHAR  errorUTF8[XMLSEC_MSCRYPTO_ERROR_MSG_BUFFER_SIZE];
+    xmlChar buf[XMLSEC_MSCRYPTO_ERROR_MSG_BUFFER_SIZE];
+    DWORD rc;
+    int ret;
 
     dwError = GetLastError();
-    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
-                  FORMAT_MESSAGE_FROM_SYSTEM |
-                  FORMAT_MESSAGE_IGNORE_INSERTS,
+    rc = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
                   NULL,
                   dwError,
                   MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
-                  (LPTSTR) &lpMsgBuf,
-                  0,
+                  errorT,
+                  XMLSEC_MSCRYPTO_ERROR_MSG_BUFFER_SIZE,
                   NULL);
+    
+#ifdef UNICODE
+    if(rc <= 0) {
+        wcscpy_s(errorT, XMLSEC_MSCRYPTO_ERROR_MSG_BUFFER_SIZE, L"");
+    }
+    ret = WideCharToMultiByte(CP_UTF8, 0, errorT, -1, errorUTF8, XMLSEC_MSCRYPTO_ERROR_MSG_BUFFER_SIZE, NULL, NULL);
+    if(ret <= 0) {
+        strcpy_s(errorUTF8, XMLSEC_MSCRYPTO_ERROR_MSG_BUFFER_SIZE, "");
+    }
+#else /* UNICODE */
+    if(rc <= 0) {
+        strcpy_s(errorT, XMLSEC_MSCRYPTO_ERROR_MSG_BUFFER_SIZE, "");
+    }
+    ret = MultiByteToWideChar(CP_ACP, 0, errorT, -1, errorW, XMLSEC_MSCRYPTO_ERROR_MSG_BUFFER_SIZE);
+    if(ret <= 0) {
+        wcscpy_s(errorW, XMLSEC_MSCRYPTO_ERROR_MSG_BUFFER_SIZE, L"");
+    }
+    ret = WideCharToMultiByte(CP_UTF8, 0, errorW, -1, errorUTF8, XMLSEC_MSCRYPTO_ERROR_MSG_BUFFER_SIZE, NULL, NULL);
+    if(ret <= 0) {
+        strcpy_s(errorUTF8, XMLSEC_MSCRYPTO_ERROR_MSG_BUFFER_SIZE, "");
+    }
+#endif /* UNICODE */
+
     if((msg != NULL) && ((*msg) != '\0')) {
-        xmlSecStrPrintf(buf, sizeof(buf), BAD_CAST "%s;last error=%d (0x%08x);last error msg=%s", msg, dwError, dwError, (LPTSTR)lpMsgBuf);
+        xmlSecStrPrintf(buf, sizeof(buf), BAD_CAST "%s;last error=%d (0x%08x);last error msg=%s", msg, dwError, dwError, errorUTF8);
     } else {
-        xmlSecStrPrintf(buf, sizeof(buf), BAD_CAST "last error=%d (0x%08x);last error msg=%s", dwError, dwError, (LPTSTR)lpMsgBuf);
+        xmlSecStrPrintf(buf, sizeof(buf), BAD_CAST "last error=%d (0x%08x);last error msg=%s", dwError, dwError, errorUTF8);
     }
     xmlSecErrorsDefaultCallback(file, line, func,
                 errorObject, errorSubject,
                 reason, (char*)buf);
-
-    LocalFree(lpMsgBuf);
 }
 
 /**
@@ -505,39 +537,183 @@ xmlSecMSCryptoConvertUnicodeToUtf8(LPCWSTR str) {
  */
 LPWSTR
 xmlSecMSCryptoConvertLocaleToUnicode(const char* str) {
-        LPWSTR res = NULL;
-        int len;
-        int ret;
+    LPWSTR res = NULL;
+    int len;
+    int ret;
 
     xmlSecAssert2(str != NULL, NULL);
 
-        /* call MultiByteToWideChar first to get the buffer size */
-        ret = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
-        if(ret <= 0) {
-            return(NULL);
-        }
-        len = ret;
+    /* call MultiByteToWideChar first to get the buffer size */
+    ret = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
+    if(ret <= 0) {
+        return(NULL);
+    }
+    len = ret;
 
-        /* allocate buffer */
-        res = (LPWSTR)xmlMalloc(sizeof(WCHAR) * len);
-        if(res == NULL) {
-            xmlSecError(XMLSEC_ERRORS_HERE,
-                        NULL,
-                        NULL,
-                        XMLSEC_ERRORS_R_MALLOC_FAILED,
-                    XMLSEC_ERRORS_NO_MESSAGE);
+    /* allocate buffer */
+    res = (LPWSTR)xmlMalloc(sizeof(WCHAR) * len);
+    if(res == NULL) {
+        xmlSecError(XMLSEC_ERRORS_HERE,
+                    NULL,
+                    NULL,
+                    XMLSEC_ERRORS_R_MALLOC_FAILED,
+                XMLSEC_ERRORS_NO_MESSAGE);
+        return(NULL);
+    }
+
+    /* convert */
+    ret = MultiByteToWideChar(CP_ACP, 0, str, -1, res, len);
+    if(ret <= 0) {
+            xmlFree(res);
             return(NULL);
-        }
+    }
 
-        /* convert */
-        ret = MultiByteToWideChar(CP_ACP, 0, str, -1, res, len);
-        if(ret <= 0) {
-                xmlFree(res);
-                return(NULL);
-        }
+    /* done */
+    return(res);
+}
+
+/**
+ * xmlSecMSCryptoConvertLocaleToUtf8:
+ * @str:         the string to convert.
+ *
+ * Converts input string from locale to UTF8.
+ *
+ * Returns: a pointer to newly allocated string (must be freed with xmlFree) or NULL if an error occurs.
+ */
+xmlChar* 
+xmlSecMSCryptoConvertLocaleToUtf8(const char * str) {
+    LPWSTR strW = NULL;
+    xmlChar * res = NULL;
+    int len;
+    int ret;
+
+    xmlSecAssert2(str != NULL, NULL);
+
+    strW = xmlSecMSCryptoConvertLocaleToUnicode(str);
+    if(strW == NULL) {
+        return(NULL);
+    }
+
+    /* call WideCharToMultiByte first to get the buffer size */
+    ret = WideCharToMultiByte(CP_ACP, 0, strW, -1, NULL, 0, NULL, NULL);
+    if(ret <= 0) {
+        xmlFree(strW);
+        return(NULL);
+    }
+    len = ret + 1;
 
-        /* done */
-        return(res);
+    /* allocate buffer */
+    res = (xmlChar*)xmlMalloc(sizeof(xmlChar) * len);
+    if(res == NULL) {
+        xmlSecError(XMLSEC_ERRORS_HERE,
+                    NULL,
+                    NULL,
+                    XMLSEC_ERRORS_R_MALLOC_FAILED,
+                    "size=%d", sizeof(xmlChar) * len);
+        xmlFree(strW);
+        return(NULL);
+    }
+
+    /* convert */
+    ret = WideCharToMultiByte(CP_ACP, 0, strW, -1, res, len, NULL, NULL);
+    if(ret <= 0) {
+        xmlFree(strW);
+        xmlFree(res);
+        return(NULL);
+    }
+
+    /* done */
+    xmlFree(strW);
+    return(res);
+}
+
+/**
+ * xmlSecMSCryptoConvertUtf8ToLocale:
+ * @str:         the string to convert.
+ *
+ * Converts input string from UTF8 to locale.
+ *
+ * Returns: a pointer to newly allocated string (must be freed with xmlFree) or NULL if an error occurs.
+ */
+char * 
+xmlSecMSCryptoConvertUtf8ToLocale(const xmlChar* str) {
+    LPWSTR strW = NULL;
+    char * res = NULL;
+    int len;
+    int ret;
+
+    xmlSecAssert2(str != NULL, NULL);
+
+    strW = xmlSecMSCryptoConvertUtf8ToUnicode(str);
+    if(strW == NULL) {
+        return(NULL);
+    }
+
+    /* call WideCharToMultiByte first to get the buffer size */
+    ret = WideCharToMultiByte(CP_ACP, 0, strW, -1, NULL, 0, NULL, NULL);
+    if(ret <= 0) {
+        xmlFree(strW);
+        return(NULL);
+    }
+    len = ret + 1;
+
+    /* allocate buffer */
+    res = (char*)xmlMalloc(sizeof(char) * len);
+    if(res == NULL) {
+        xmlSecError(XMLSEC_ERRORS_HERE,
+                    NULL,
+                    NULL,
+                    XMLSEC_ERRORS_R_MALLOC_FAILED,
+                    "size=%d", sizeof(xmlChar) * len);
+        xmlFree(strW);
+        return(NULL);
+    }
+
+    /* convert */
+    ret = WideCharToMultiByte(CP_ACP, 0, strW, -1, res, len, NULL, NULL);
+    if(ret <= 0) {
+        xmlFree(strW);
+        xmlFree(res);
+        return(NULL);
+    }
+
+    /* done */
+    xmlFree(strW);
+    return(res);
+}
+
+/**
+ * xmlSecMSCryptoConvertTstrToUtf8:
+ * @str:         the string to convert.
+ *
+ * Converts input string from TSTR (locale or Unicode) to UTF8.
+ *
+ * Returns: a pointer to newly allocated string (must be freed with xmlFree) or NULL if an error occurs.
+ */
+xmlChar* 
+xmlSecMSCryptoConvertTstrToUtf8(LPCTSTR str) {
+#ifdef UNICODE
+    return xmlSecMSCryptoConvertUnicodeToUtf8(str);
+#else  /* UNICODE */
+    return xmlSecMSCryptoConvertLocaleToUtf8(str);
+#endif /* UNICODE */
+}
+
+/**
+ * xmlSecMSCryptoConvertUtf8ToTstr:
+ * @str:         the string to convert.
+ *
+ * Converts input string from UTF8 to TSTR (locale or Unicode).
+ *
+ * Returns: a pointer to newly allocated string (must be freed with xmlFree) or NULL if an error occurs.
+ */
+LPTSTR
+xmlSecMSCryptoConvertUtf8ToTstr(const xmlChar*  str) {
+#ifdef UNICODE
+    return xmlSecMSCryptoConvertUtf8ToUnicode(str);
+#else  /* UNICODE */
+    return xmlSecMSCryptoConvertUtf8ToLocale(str);
+#endif /* UNICODE */
 }
 
 /**
diff --git a/src/mscrypto/csp_calg.h b/src/mscrypto/csp_calg.h
index c100984..984fe34 100644
--- a/src/mscrypto/csp_calg.h
+++ b/src/mscrypto/csp_calg.h
@@ -72,11 +72,23 @@
  *
  * @{
  */
-#define MAGPRO_CSP                  "MagPro CSP"
 #define PROV_MAGPRO_GOST            501
+#define MAGPRO_CSP_A                "MagPro CSP"
+#define MAGPRO_CSP_W                L"MagPro CSP"
+#ifdef UNICODE
+#define MAGPRO_CSP MAGPRO_CSP_W
+#else
+#define MAGPRO_CSP MAGPRO_CSP_A
+#endif
 
-#define CRYPTOPRO_CSP               "CryptoPro CSP"
 #define PROV_CRYPTOPRO_GOST         75
+#define CRYPTOPRO_CSP_A             "CryptoPro CSP"
+#define CRYPTOPRO_CSP_W             L"CryptoPro CSP"
+#ifdef UNICODE
+#define CRYPTOPRO_CSP CRYPTOPRO_CSP_W
+#else
+#define CRYPTOPRO_CSP CRYPTOPRO_CSP_A
+#endif
 
 /*! @} */
 /*! \defgroup PP_MAGPRO PP_MAGPRO
diff --git a/src/mscrypto/keysstore.c b/src/mscrypto/keysstore.c
index 108706a..2e5a468 100644
--- a/src/mscrypto/keysstore.c
+++ b/src/mscrypto/keysstore.c
@@ -43,7 +43,13 @@
 #  include "xmlsec-mingw.h"
 #endif
 
-#define XMLSEC_MSCRYPTO_APP_DEFAULT_CERT_STORE_NAME     "MY"
+#define XMLSEC_MSCRYPTO_APP_DEFAULT_CERT_STORE_NAME_A     "MY"
+#define XMLSEC_MSCRYPTO_APP_DEFAULT_CERT_STORE_NAME_W     L"MY"
+#ifdef UNICODE
+#define XMLSEC_MSCRYPTO_APP_DEFAULT_CERT_STORE_NAME XMLSEC_MSCRYPTO_APP_DEFAULT_CERT_STORE_NAME_W
+#else  /* UNICODE */
+#define XMLSEC_MSCRYPTO_APP_DEFAULT_CERT_STORE_NAME XMLSEC_MSCRYPTO_APP_DEFAULT_CERT_STORE_NAME_A
+#endif /* UNICODE */
 
 /****************************************************************************
  *
@@ -305,10 +311,10 @@ xmlSecMSCryptoKeysStoreFinalize(xmlSecKeyStorePtr store) {
 static PCCERT_CONTEXT
 xmlSecMSCryptoKeysStoreFindCert(xmlSecKeyStorePtr store, const xmlChar* name,
                                 xmlSecKeyInfoCtxPtr keyInfoCtx) {
-    const char* storeName;
+    LPCTSTR storeName;
     HCERTSTORE hStoreHandle = NULL;
     PCCERT_CONTEXT pCertContext = NULL;
-    LPWSTR wcName = NULL;
+    LPTSTR wcName = NULL;
 
     xmlSecAssert2(xmlSecKeyStoreCheckId(store, xmlSecMSCryptoKeysStoreId), NULL);
     xmlSecAssert2(name != NULL, NULL);
@@ -331,7 +337,7 @@ xmlSecMSCryptoKeysStoreFindCert(xmlSecKeyStorePtr store, const xmlChar* name,
     }
 
     /* convert name to unicode */
-    wcName = xmlSecMSCryptoConvertUtf8ToUnicode(name);
+    wcName = xmlSecMSCryptoConvertUtf8ToTstr(name);
     if(wcName == NULL) {
         xmlSecError(XMLSEC_ERRORS_HERE,
                         xmlSecErrorsSafeString(xmlSecKeyStoreGetName(store)),
@@ -388,7 +394,7 @@ xmlSecMSCryptoKeysStoreFindCert(xmlSecKeyStorePtr store, const xmlChar* name,
             }
 
             /* Compare FriendlyName to name */
-            if (!wcscmp(wcName, (const wchar_t *)pbFriendlyName)) {
+            if (!lstrcmp(wcName, (LPCTSTR)pbFriendlyName)) {
               pCertContext = pCertCtxIter;
               xmlFree(pbFriendlyName);
               break;
diff --git a/src/mscrypto/x509.c b/src/mscrypto/x509.c
index 19adfb7..8d720d7 100644
--- a/src/mscrypto/x509.c
+++ b/src/mscrypto/x509.c
@@ -1881,7 +1881,7 @@ xmlSecMSCryptoX509CrlBase64DerWrite(PCCRL_CONTEXT crl, int base64LineWrap) {
 
 static xmlChar*
 xmlSecMSCryptoX509NameWrite(PCERT_NAME_BLOB nm) {
-    LPWSTR resW = NULL;
+    LPTSTR resT = NULL;
     xmlChar *res = NULL;
     DWORD csz;
 
@@ -1889,7 +1889,7 @@ xmlSecMSCryptoX509NameWrite(PCERT_NAME_BLOB nm) {
     xmlSecAssert2(nm->pbData != NULL, NULL);
     xmlSecAssert2(nm->cbData > 0, NULL);
 
-    csz = CertNameToStrW(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, nm, CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG, NULL, 0);
+    csz = CertNameToStr(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, nm, CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG, NULL, 0);
     if(csz <= 0) {
         xmlSecError(XMLSEC_ERRORS_HERE,
                     NULL,
@@ -1899,8 +1899,8 @@ xmlSecMSCryptoX509NameWrite(PCERT_NAME_BLOB nm) {
         return(NULL);
     }
 
-    resW = (LPWSTR)xmlMalloc(sizeof(WCHAR) * (csz + 1));
-    if (NULL == resW) {
+    resT = (LPTSTR)xmlMalloc(sizeof(TCHAR) * (csz + 1));
+    if (NULL == resT) {
         xmlSecError(XMLSEC_ERRORS_HERE,
                     NULL,
                     "xmlMalloc",
@@ -1909,25 +1909,25 @@ xmlSecMSCryptoX509NameWrite(PCERT_NAME_BLOB nm) {
         return (NULL);
     }
 
-    csz = CertNameToStrW(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, nm, CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG, resW, csz + 1);
+    csz = CertNameToStr(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, nm, CERT_X500_NAME_STR | CERT_NAME_STR_REVERSE_FLAG, resT, csz + 1);
     if (csz <= 0) {
         xmlSecError(XMLSEC_ERRORS_HERE,
                     NULL,
                     "CertNameToStr",
                     XMLSEC_ERRORS_R_CRYPTO_FAILED,
                     XMLSEC_ERRORS_NO_MESSAGE);
-        xmlFree(resW);
+        xmlFree(resT);
         return(NULL);
     }
 
-    res = xmlSecMSCryptoConvertUnicodeToUtf8(resW);
+    res = xmlSecMSCryptoConvertTstrToUtf8(resT);
     if (NULL == res) {
         xmlSecError(XMLSEC_ERRORS_HERE,
                     NULL,
-                    "xmlSecMSCryptoConvertUnicodeToUtf8",
+                    "xmlSecMSCryptoConvertTstrToUtf8",
                     XMLSEC_ERRORS_R_XMLSEC_FAILED,
                     XMLSEC_ERRORS_NO_MESSAGE);
-        xmlFree(resW);
+        xmlFree(resT);
         return(NULL);
     }
 
@@ -2056,27 +2056,40 @@ static void
 xmlSecMSCryptoX509CertDebugDump(PCCERT_CONTEXT cert, FILE* output) {
     PCRYPT_INTEGER_BLOB sn;
     unsigned int i;
-    LPSTR subject, issuer;
-    DWORD dwSize;
-
+    xmlChar * subject = NULL;
+    xmlChar * issuer = NULL;
+    
     xmlSecAssert(cert != NULL);
     xmlSecAssert(output != NULL);
 
-    /* todo: add error checks */
-    dwSize = CertGetNameString(cert, CERT_NAME_RDN_TYPE, 0, NULL, NULL, 0);
-    subject = (LPSTR)xmlMalloc(dwSize);
-    dwSize = CertGetNameString(cert, CERT_NAME_RDN_TYPE, 0, NULL, subject, dwSize);
-    dwSize = CertGetNameString(cert, CERT_NAME_RDN_TYPE, CERT_NAME_ISSUER_FLAG, NULL, NULL, 0);
-    issuer = (LPSTR)xmlMalloc(dwSize);
-    dwSize = CertGetNameString(cert, CERT_NAME_RDN_TYPE, CERT_NAME_ISSUER_FLAG, NULL, issuer, dwSize);
-
     fprintf(output, "=== X509 Certificate\n");
+
+    /* subject */
+    subject = xmlSecMSCryptoX509GetNameString(cert, CERT_NAME_RDN_TYPE, 0, NULL);
+    if(subject == NULL) {
+        xmlSecError(XMLSEC_ERRORS_HERE,
+                    "xmlSecMSCryptoX509GetNameString",
+                    NULL,
+                    XMLSEC_ERRORS_R_XMLSEC_FAILED,
+                    "subject");
+        goto done;
+    }
     fprintf(output, "==== Subject Name: %s\n", subject);
+
+    /* issuer */
+    issuer = xmlSecMSCryptoX509GetNameString(cert, CERT_NAME_RDN_TYPE, CERT_NAME_ISSUER_FLAG, NULL);
+    if(issuer == NULL) {
+        xmlSecError(XMLSEC_ERRORS_HERE,
+                    "xmlSecMSCryptoX509GetNameString",
+                    NULL,
+                    XMLSEC_ERRORS_R_XMLSEC_FAILED,
+                    "issuer");
+        goto done;
+    }
     fprintf(output, "==== Issuer Name: %s\n", issuer);
-    if (subject) xmlFree(subject);
-    if (issuer) xmlFree(issuer);
-    sn = &(cert->pCertInfo->SerialNumber);
 
+    /* serial number */
+    sn = &(cert->pCertInfo->SerialNumber);
     for (i = 0; i < sn->cbData; i++) {
         if (i != sn->cbData - 1) {
             fprintf(output, "%02x:", sn->pbData[i]);
@@ -2085,6 +2098,10 @@ xmlSecMSCryptoX509CertDebugDump(PCCERT_CONTEXT cert, FILE* output) {
         }
     }
     fprintf(output, "\n");
+
+done:
+    if (subject) xmlFree(subject);
+    if (issuer) xmlFree(issuer);
 }
 
 
@@ -2092,34 +2109,39 @@ static void
 xmlSecMSCryptoX509CertDebugXmlDump(PCCERT_CONTEXT cert, FILE* output) {
     PCRYPT_INTEGER_BLOB sn;
     unsigned int i;
-    LPSTR subject, issuer;
-    DWORD dwSize;
+    xmlChar * subject = NULL;
+    xmlChar * issuer = NULL;
 
     xmlSecAssert(cert != NULL);
     xmlSecAssert(output != NULL);
 
-    /* todo: add error checks */
-
     /* subject */
-    dwSize = CertGetNameString(cert, CERT_NAME_RDN_TYPE, 0, NULL, NULL, 0);
-    subject = (LPSTR)xmlMalloc(dwSize);
-    dwSize = CertGetNameString(cert, CERT_NAME_RDN_TYPE, 0, NULL, subject, dwSize);
-
+    subject = xmlSecMSCryptoX509GetNameString(cert, CERT_NAME_RDN_TYPE, 0, NULL);
+    if(subject == NULL) {
+        xmlSecError(XMLSEC_ERRORS_HERE,
+                    "xmlSecMSCryptoX509GetNameString",
+                    NULL,
+                    XMLSEC_ERRORS_R_XMLSEC_FAILED,
+                    "subject");
+        goto done;
+    }
     fprintf(output, "<SubjectName>");
     xmlSecPrintXmlString(output, BAD_CAST subject);
     fprintf(output, "</SubjectName>\n");
-    xmlFree(subject);
-
 
     /* issuer */
-    dwSize = CertGetNameString(cert, CERT_NAME_RDN_TYPE, CERT_NAME_ISSUER_FLAG, NULL, NULL, 0);
-    issuer = (LPSTR)xmlMalloc(dwSize);
-    dwSize = CertGetNameString(cert, CERT_NAME_RDN_TYPE, CERT_NAME_ISSUER_FLAG, NULL, issuer, dwSize);
-
+    issuer = xmlSecMSCryptoX509GetNameString(cert, CERT_NAME_RDN_TYPE, CERT_NAME_ISSUER_FLAG, NULL);
+    if(issuer == NULL) {
+        xmlSecError(XMLSEC_ERRORS_HERE,
+                    "xmlSecMSCryptoX509GetNameString",
+                    NULL,
+                    XMLSEC_ERRORS_R_XMLSEC_FAILED,
+                    "issuer");
+        goto done;
+    }
     fprintf(output, "<IssuerName>");
     xmlSecPrintXmlString(output, BAD_CAST issuer);
     fprintf(output, "</IssuerName>\n");
-    xmlFree(issuer);
 
     /* serial */
     fprintf(output, "<SerialNumber>");
@@ -2132,6 +2154,10 @@ xmlSecMSCryptoX509CertDebugXmlDump(PCCERT_CONTEXT cert, FILE* output) {
         }
     }
     fprintf(output, "</SerialNumber>\n");
+
+done:
+    xmlFree(subject);
+    xmlFree(issuer);
 }
 
 
diff --git a/src/mscrypto/x509vfy.c b/src/mscrypto/x509vfy.c
index 368dc3a..c8d1daf 100644
--- a/src/mscrypto/x509vfy.c
+++ b/src/mscrypto/x509vfy.c
@@ -199,7 +199,7 @@ xmlSecMSCryptoCheckRevocation(HCERTSTORE hStore, PCCERT_CONTEXT pCert) {
 
 static void
 xmlSecMSCryptoX509StoreCertError(xmlSecKeyDataStorePtr store, PCCERT_CONTEXT cert, DWORD flags) {
-    LPSTR subject;
+    xmlChar * subject = NULL;
     DWORD dwSize;
 
     xmlSecAssert(xmlSecKeyDataStoreCheckId(store, xmlSecMSCryptoX509StoreId));
@@ -207,20 +207,15 @@ xmlSecMSCryptoX509StoreCertError(xmlSecKeyDataStorePtr store, PCCERT_CONTEXT cer
     xmlSecAssert(flags != 0);
 
     /* get certs subject */
-    dwSize = CertGetNameString(cert, CERT_NAME_RDN_TYPE, 0, NULL, NULL, 0);
-    subject = xmlMalloc(dwSize + 1);
+    subject = xmlSecMSCryptoX509GetNameString(cert, CERT_NAME_RDN_TYPE, 0, NULL);
     if(subject == NULL) {
         xmlSecError(XMLSEC_ERRORS_HERE,
+            "xmlSecMSCryptoX509GetNameString",
             NULL,
-            NULL,
-            XMLSEC_ERRORS_R_MALLOC_FAILED,
+            XMLSEC_ERRORS_R_XMLSEC_FAILED,
             XMLSEC_ERRORS_NO_MESSAGE);
         return;
     }
-    memset(subject, 0, dwSize + 1);
-    if(dwSize > 0) {
-        CertGetNameString(cert, CERT_NAME_RDN_TYPE, 0, NULL, subject, dwSize);
-    }
 
     /* print error */
     if (flags & CERT_STORE_SIGNATURE_FLAG) {
@@ -256,6 +251,7 @@ xmlSecMSCryptoX509StoreCertError(xmlSecKeyDataStorePtr store, PCCERT_CONTEXT cer
                 XMLSEC_ERRORS_R_CERT_VERIFY_FAILED,
                 XMLSEC_ERRORS_NO_MESSAGE);
     }
+
     xmlFree(subject);
 }
 
@@ -896,21 +892,21 @@ xmlSecMSCryptoX509StoreFinalize(xmlSecKeyDataStorePtr store) {
  * Returns: a pointer to newly allocated string or NULL if an error occurs.
  */
 static BYTE*
-xmlSecMSCryptoCertStrToName(DWORD dwCertEncodingType, LPWSTR pszX500, DWORD dwStrType, DWORD* len) {
+xmlSecMSCryptoCertStrToName(DWORD dwCertEncodingType, LPTSTR pszX500, DWORD dwStrType, DWORD* len) {
     BYTE* str = NULL;
-    LPCWSTR ppszError = NULL;
+    LPCTSTR ppszError = NULL;
 
     xmlSecAssert2(pszX500 != NULL, NULL);
     xmlSecAssert2(len != NULL, NULL);
 
-    if (!CertStrToNameW(dwCertEncodingType, pszX500, dwStrType,
+    if (!CertStrToName(dwCertEncodingType, pszX500, dwStrType,
                         NULL, NULL, len, &ppszError)) {
         /* this might not be an error, string might just not exist */
-                DWORD dw = GetLastError();
+        DWORD dw = GetLastError();
         return(NULL);
     }
 
-    str = (BYTE *)xmlMalloc((*len) + 1);
+    str = (BYTE *)xmlMalloc(sizeof(TCHAR) * ((*len) + 1));
     if(str == NULL) {
         xmlSecError(XMLSEC_ERRORS_HERE,
                     NULL,
@@ -921,7 +917,7 @@ xmlSecMSCryptoCertStrToName(DWORD dwCertEncodingType, LPWSTR pszX500, DWORD dwSt
     }
     memset(str, 0, (*len) + 1);
 
-    if (!CertStrToNameW(dwCertEncodingType, pszX500, dwStrType,
+    if (!CertStrToName(dwCertEncodingType, pszX500, dwStrType,
                         NULL, str, len, NULL)) {
         xmlSecError(XMLSEC_ERRORS_HERE,
                         NULL,
@@ -947,7 +943,7 @@ xmlSecMSCryptoCertStrToName(DWORD dwCertEncodingType, LPWSTR pszX500, DWORD dwSt
  * Returns: cert handle on success or NULL otherwise
  */
 PCCERT_CONTEXT
-xmlSecMSCryptoX509FindCertBySubject(HCERTSTORE store, const LPWSTR wcSubject, DWORD dwCertEncodingType) {
+xmlSecMSCryptoX509FindCertBySubject(HCERTSTORE store, const LPTSTR wcSubject, DWORD dwCertEncodingType) {
     PCCERT_CONTEXT res = NULL;
     CERT_NAME_BLOB cnb;
     BYTE* bdata;
@@ -1053,7 +1049,7 @@ xmlSecMSCryptoX509FindCertBySubject(HCERTSTORE store, const LPWSTR wcSubject, DW
  * Returns: cert handle on success or NULL otherwise
  */
 static PCCERT_CONTEXT
-xmlSecMSCryptoX509FindCertByIssuer(HCERTSTORE store, const LPWSTR wcIssuer,
+xmlSecMSCryptoX509FindCertByIssuer(HCERTSTORE store, const LPTSTR wcIssuer,
                                    xmlSecBnPtr issuerSerialBn, DWORD dwCertEncodingType) {
 
     PCCERT_CONTEXT res = NULL;
@@ -1155,11 +1151,11 @@ xmlSecMSCryptoX509FindCertByIssuer(HCERTSTORE store, const LPWSTR wcIssuer,
     return (res);
 }
 
-static LPWSTR 
+static LPTSTR 
 xmlSecMSCryptoX509GetCertName(const xmlChar * name) {
     xmlChar *name2 = NULL;
     xmlChar *p = NULL;
-    LPWSTR res = NULL;
+    LPTSTR res = NULL;
 
     xmlSecAssert2(name != 0, NULL);
 
@@ -1182,12 +1178,12 @@ xmlSecMSCryptoX509GetCertName(const xmlChar * name) {
         memcpy(p, "           E=", 13);
     }
 
-    /* get unicode name */
-    res = xmlSecMSCryptoConvertUtf8ToUnicode(name2);
+    /* get name */
+    res = xmlSecMSCryptoConvertUtf8ToTstr(name2);
     if(res == NULL) {
         xmlSecError(XMLSEC_ERRORS_HERE,
                     NULL,
-                    "xmlSecMSCryptoConvertUtf8ToUnicode",
+                    "xmlSecMSCryptoConvertUtf8ToTstr",
                     XMLSEC_ERRORS_R_XMLSEC_FAILED,
                     XMLSEC_ERRORS_NO_MESSAGE);
         return(NULL);
@@ -1209,7 +1205,7 @@ xmlSecMSCryptoX509FindCert(HCERTSTORE store,
     xmlSecAssert2(store != 0, NULL);
 
     if((pCert == NULL) && (NULL != subjectName)) {
-        LPWSTR wcSubjectName = NULL;
+        LPTSTR wcSubjectName = NULL;
 
         /* get unicode subject name */
         wcSubjectName = xmlSecMSCryptoX509GetCertName(subjectName);
@@ -1234,7 +1230,7 @@ xmlSecMSCryptoX509FindCert(HCERTSTORE store,
 
     if((pCert == NULL) && (NULL != issuerName) && (NULL != issuerSerial)) {
         xmlSecBn issuerSerialBn;
-        LPWSTR wcIssuerName = NULL;
+        LPTSTR wcIssuerName = NULL;
 
         /* get serial number */
         ret = xmlSecBnInitialize(&issuerSerialBn, 0);
@@ -1340,6 +1336,74 @@ xmlSecMSCryptoX509FindCert(HCERTSTORE store,
 }
 
 
+/**
+ * xmlSecMSCryptoX509GetNameString:
+ * @pCertContext:   the pointer to cert
+ * @dwType:         the type (see CertGetNameString description in MSDN)
+ * @dwFlags:        the flags (see CertGetNameString description in MSDN)
+ * @pvTypePara:     the type parameter (see CertGetNameString description in MSDN)
+ *
+ * Gets the name string for certificate (see CertGetNameString description in MSDN).
+ *
+ * Returns: name string (should be freed with xmlFree) or NULL if failed.
+ */
+xmlChar *
+xmlSecMSCryptoX509GetNameString(PCCERT_CONTEXT pCertContext, DWORD dwType, DWORD dwFlags, void *pvTypePara) {
+    LPTSTR name = NULL;
+    xmlChar * res = NULL;
+    DWORD dwSize;
+
+    xmlSecAssert2(pCertContext != NULL, NULL);
+
+    /* get size first */
+    dwSize = CertGetNameString(pCertContext, dwType, dwFlags, pvTypePara, NULL, 0);
+    if(dwSize <= 0) {
+        xmlSecError(XMLSEC_ERRORS_HERE,
+                    "CertGetNameString",
+                    NULL,
+                    XMLSEC_ERRORS_R_CRYPTO_FAILED,
+                    XMLSEC_ERRORS_NO_MESSAGE);
+        return (NULL);
+    }
+
+    /* allocate buffer */
+    name = (LPTSTR)xmlMalloc(sizeof(TCHAR) * (dwSize + 1));
+    if(name == NULL) {
+        xmlSecError(XMLSEC_ERRORS_HERE,
+                    NULL,
+                    NULL,
+                    XMLSEC_ERRORS_R_MALLOC_FAILED,
+                    XMLSEC_ERRORS_NO_MESSAGE);
+        return (NULL);
+    }
+
+    /* actually get the name */
+    dwSize = CertGetNameString(pCertContext, dwType, dwFlags, pvTypePara, name, dwSize);
+    if(dwSize <= 0) {
+        xmlSecError(XMLSEC_ERRORS_HERE,
+                    "CertGetNameString",
+                    NULL,
+                    XMLSEC_ERRORS_R_CRYPTO_FAILED,
+                    XMLSEC_ERRORS_NO_MESSAGE);
+        xmlFree(name);
+        return (NULL);
+    }
+
+    res = xmlSecMSCryptoConvertTstrToUtf8(name);
+    if(res == NULL) {
+        xmlSecError(XMLSEC_ERRORS_HERE,
+                    "xmlSecMSCryptoConvertTstrToUtf8",
+                    NULL,
+                    XMLSEC_ERRORS_R_XMLSEC_FAILED,
+                    XMLSEC_ERRORS_NO_MESSAGE);
+        xmlFree(name);
+        return (NULL);
+    }
+    /* done */
+    xmlFree(name);
+    return (res);
+}
+
 #endif /* XMLSEC_NO_X509 */
 
 
diff --git a/src/mscrypto/xmlsec-mingw.h b/src/mscrypto/xmlsec-mingw.h
index efd7cbf..85391e4 100644
--- a/src/mscrypto/xmlsec-mingw.h
+++ b/src/mscrypto/xmlsec-mingw.h
@@ -140,9 +140,9 @@ BOOL            WINAPI CertStrToNameW(DWORD,LPCWSTR,DWORD,void*,BYTE*,DWORD*,LPC
 #else
 #define CertStrToName  CertStrToNameA
 #endif
-
-DWORD          WINAPI CertNameToStrA(DWORD,PCERT_NAME_BLOB,DWORD,LPCSTR,DWORD);
-DWORD          WINAPI CertNameToStrW(DWORD,PCERT_NAME_BLOB,DWORD,LPCWSTR,DWORD);
+
+DWORD          WINAPI CertNameToStrA(DWORD,PCERT_NAME_BLOB,DWORD,LPCSTR,DWORD);
+DWORD          WINAPI CertNameToStrW(DWORD,PCERT_NAME_BLOB,DWORD,LPCWSTR,DWORD);
 #ifdef UNICODE
 #define CertNameToStr  CertNameToStrA
 #else
diff --git a/win32/Makefile.msvc b/win32/Makefile.msvc
index 2e1cc6f..2577a1e 100644
--- a/win32/Makefile.msvc
+++ b/win32/Makefile.msvc
@@ -30,6 +30,7 @@ AUTOCONF = .\configure.txt
 #XMLSEC_MINOR_VERSION = 0 # set this to the right value.
 #XMLSEC_MICRO_VERSION = 0 # set this to the right value.
 #WITH_XMLSEC_DEBUG = 1
+#UNICODE = 1
 #DEBUG = 0
 #WITH_CRYPTO=openssl
 #WITH_CRYPTO=openssl
@@ -305,6 +306,10 @@ CFLAGS 			= $(CFLAGS) /D "HAVE_STDIO_H" /D "HAVE_STDLIB_H"
 CFLAGS 			= $(CFLAGS) /D "HAVE_STRING_H" /D "HAVE_CTYPE_H"
 CFLAGS 			= $(CFLAGS) /D "HAVE_MALLOC_H" /D "HAVE_MEMORY_H"
 
+!if "$(UNICODE)" == "1"
+CFLAGS 			= $(CFLAGS) /D "UNICODE" /D "_UNICODE"
+!endif
+
 # Optimisation and debug symbols.
 !if "$(DEBUG)" == "1"
 CFLAGS 			= $(CFLAGS) /D "_DEBUG" /Od /Z7
diff --git a/win32/configure.js b/win32/configure.js
index 02625b6..6b6294f 100644
--- a/win32/configure.js
+++ b/win32/configure.js
@@ -48,6 +48,7 @@ var withIconv = 1;
 var withNT4 = 0;
 
 /* Win32 build options. */
+var buildUnicode = 1;
 var buildDebug = 0;
 var buildStatic = 1;
 var buildWithDLSupport = 1;
@@ -102,6 +103,7 @@ function usage()
  	txt += "  iconv:      Use the iconv library (" + (withIconv? "yes" : "no")  + ")\n";	
  	txt += "  nt4:        Enable NT 4.0 support (" + (withNT4? "yes" : "no")  + ")\n";	
 	txt += "\nWin32 build options, default value given in parentheses:\n\n";
+	txt += "  unicode:    Build Unicode version (" + (buildUnicode? "yes" : "no")  + ")\n";
 	txt += "  debug:      Build unoptimised debug executables (" + (buildDebug? "yes" : "no")  + ")\n";
 	txt += "  static:     Link libxmlsec statically to xmlsec (" + (buildStatic? "yes" : "no")  + ")\n";
 	txt += "  with-dl:    Enable dynamic loading of xmlsec-crypto libraries (" + (buildWithDLSupport? "yes" : "no")  + ")\n";
@@ -163,6 +165,7 @@ function discoverVersion()
 	vf.WriteLine("WITH_LIBXSLT=" + (withLibXSLT ? "1" : "0"));
 	vf.WriteLine("WITH_ICONV=" + (withIconv ? "1" : "0"));
 	vf.WriteLine("WITH_NT4=" + (withNT4 ? "1" : "0"));
+	vf.WriteLine("UNICODE=" + (buildUnicode? "1" : "0"));
 	vf.WriteLine("DEBUG=" + (buildDebug? "1" : "0"));
 	vf.WriteLine("STATIC=" + (buildStatic? "1" : "0"));
 	vf.WriteLine("WITH_DL=" + (buildWithDLSupport ? "1" : "0"));
@@ -254,6 +257,8 @@ for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) {
 			withIconv = strToBool(arg.substring(opt.length + 1, arg.length));
 		else if (opt == "nt4")
 			withNT4 = strToBool(arg.substring(opt.length + 1, arg.length));
+		else if (opt == "unicode")
+			buildUnicode = strToBool(arg.substring(opt.length + 1, arg.length));
 		else if (opt == "debug")
 			buildDebug = strToBool(arg.substring(opt.length + 1, arg.length));
 		else if (opt == "static")
@@ -374,6 +379,7 @@ txtOut += "     NT 4.0 support: " + boolToStr(withNT4) + "\n";
 txtOut += "\n";
 txtOut += "Win32 build configuration\n";
 txtOut += "-------------------------\n";
+txtOut += "           Unicode: " + boolToStr(buildUnicode) + "\n";
 txtOut += "     Debug symbols: " + boolToStr(buildDebug) + "\n";
 txtOut += "     Static xmlsec: " + boolToStr(buildStatic) + "\n";
 txtOut += "  Enable DL suport: " + boolToStr(buildWithDLSupport) + "\n";
diff --git a/win32/mycfg.bat b/win32/mycfg.bat
index c4994c7..66af38e 100644
--- a/win32/mycfg.bat
+++ b/win32/mycfg.bat
@@ -11,7 +11,7 @@ REM
 SET PREFIX=C:\cygwin\home\local
 SET XMLSEC_INCLUDE=%PREFIX%\include;%PREFIX%\include\mozilla;%PREFIX%\include\mozilla\nspr;%PREFIX%\include\mozilla\nss;%MSSDK_INCLUDE%
 SET XMLSEC_LIB=%PREFIX%\lib;%MSSDK_LIB%
-SET XMLSEC_OPTIONS=static=no iconv=no nt4=yes debug=yes xslt=yes crypto=mscrypto
+SET XMLSEC_OPTIONS=static=no iconv=no nt4=yes debug=yes xslt=yes crypto=mscrypto unicode=yes
 
 del /F Makefile configure.txt
 cscript configure.js prefix=%PREFIX% %XMLSEC_OPTIONS% include=%XMLSEC_INCLUDE% lib=%XMLSEC_LIB% 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]