Index: /pjproject/trunk/pjlib/include/pj/unicode.h
===================================================================
--- /pjproject/trunk/pjlib/include/pj/unicode.h	(revision 180)
+++ /pjproject/trunk/pjlib/include/pj/unicode.h	(revision 181)
@@ -21,4 +21,8 @@
 
 #include <pj/types.h>
+
+
+PJ_BEGIN_DECL
+
 
 /**
@@ -57,15 +61,19 @@
 #if defined(PJ_NATIVE_STRING_IS_UNICODE) && PJ_NATIVE_STRING_IS_UNICODE!=0
 
-#   define PJ_DECL_UNICODE_TEMP_BUF(buf,size)    wchar_t buf[size]
-#   define PJ_STRING_TO_NATIVE(s,buf)		 pj_ansi_to_unicode( \
+#   define PJ_DECL_UNICODE_TEMP_BUF(buf,size)   wchar_t buf[size];
+#   define PJ_STRING_TO_NATIVE(s,buf,max)	pj_ansi_to_unicode( \
 						    s, strlen(s), \
-						    buf, PJ_ARRAY_SIZE(buf))
-#   define PJ_TEXT(s)				 _TEXT(s)
+						    buf, max)
+#   define PJ_DECL_ANSI_TEMP_BUF(buf,size)	char buf[size];
+#   define PJ_NATIVE_TO_STRING(cs,buf,max)	pj_unicode_to_ansi( \
+						    cs, wcslen(cs), \
+						    buf, max)
 
 #else
 
 #   define PJ_DECL_UNICODE_TEMP_BUF(var,size)
-#   define PJ_STRING_TO_NATIVE(s, buf)		(s)
-#   define PJ_TEXT(s)				(s)
+#   define PJ_STRING_TO_NATIVE(s,buf,max)	((char*)s)
+#   define PJ_DECL_ANSI_TEMP_BUF(buf,size)
+#   define PJ_NATIVE_TO_STRING(cs,buf,max)	((char*)(const char*)cs)
 
 #endif
@@ -73,3 +81,6 @@
 
 
+PJ_END_DECL
+
+
 #endif	/* __PJ_UNICODE_H__ */
Index: /pjproject/trunk/pjlib/src/pj/file_access_win32.c
===================================================================
--- /pjproject/trunk/pjlib/src/pj/file_access_win32.c	(revision 180)
+++ /pjproject/trunk/pjlib/src/pj/file_access_win32.c	(revision 181)
@@ -31,10 +31,11 @@
 PJ_DEF(pj_bool_t) pj_file_exists(const char *filename)
 {
+    PJ_DECL_UNICODE_TEMP_BUF(wfilename,256)
     HANDLE hFile;
-    PJ_DECL_UNICODE_TEMP_BUF(wfilename,256);
 
     PJ_ASSERT_RETURN(filename != NULL, 0);
 
-    hFile = CreateFile(PJ_STRING_TO_NATIVE(filename,wfilename), READ_CONTROL, 
+    hFile = CreateFile(PJ_STRING_TO_NATIVE(filename,wfilename,sizeof(wfilename)), 
+		       READ_CONTROL, 
 		       FILE_SHARE_READ, NULL,
                        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
@@ -52,12 +53,13 @@
 PJ_DEF(pj_off_t) pj_file_size(const char *filename)
 {
+    PJ_DECL_UNICODE_TEMP_BUF(wfilename,256)
     HANDLE hFile;
     DWORD sizeLo, sizeHi;
     pj_off_t size;
-    PJ_DECL_UNICODE_TEMP_BUF(wfilename,256);
 
     PJ_ASSERT_RETURN(filename != NULL, -1);
 
-    hFile = CreateFile(PJ_STRING_TO_NATIVE(filename, wfilename), READ_CONTROL, 
+    hFile = CreateFile(PJ_STRING_TO_NATIVE(filename, wfilename,sizeof(wfilename)), 
+		       READ_CONTROL, 
                        FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
                        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
@@ -87,9 +89,9 @@
 PJ_DEF(pj_status_t) pj_file_delete(const char *filename)
 {
-    PJ_DECL_UNICODE_TEMP_BUF(wfilename,256);
+    PJ_DECL_UNICODE_TEMP_BUF(wfilename,256)
 
     PJ_ASSERT_RETURN(filename != NULL, PJ_EINVAL);
 
-    if (DeleteFile(PJ_STRING_TO_NATIVE(filename,wfilename)) == FALSE)
+    if (DeleteFile(PJ_STRING_TO_NATIVE(filename,wfilename,sizeof(wfilename))) == FALSE)
         return PJ_RETURN_OS_ERROR(GetLastError());
 
@@ -103,17 +105,17 @@
 PJ_DEF(pj_status_t) pj_file_move( const char *oldname, const char *newname)
 {
+    PJ_DECL_UNICODE_TEMP_BUF(woldname,256)
+    PJ_DECL_UNICODE_TEMP_BUF(wnewname,256)
     BOOL rc;
-    PJ_DECL_UNICODE_TEMP_BUF(woldname,256);
-    PJ_DECL_UNICODE_TEMP_BUF(wnewname,256);
 
     PJ_ASSERT_RETURN(oldname!=NULL && newname!=NULL, PJ_EINVAL);
 
 #if PJ_WIN32_WINNT >= 0x0400
-    rc = MoveFileEx(PJ_STRING_TO_NATIVE(oldname,woldname), 
-		    PJ_STRING_TO_NATIVE(newname,wnewname), 
+    rc = MoveFileEx(PJ_STRING_TO_NATIVE(oldname,woldname,sizeof(woldname)), 
+		    PJ_STRING_TO_NATIVE(newname,wnewname,sizeof(wnewname)), 
                     MOVEFILE_COPY_ALLOWED|MOVEFILE_REPLACE_EXISTING);
 #else
-    rc = MoveFile(PJ_STRING_TO_NATIVE(oldname, woldname), 
-		  PJ_STRING_TO_NATIVE(newname, wnewname));
+    rc = MoveFile(PJ_STRING_TO_NATIVE(oldname,woldname,sizeof(woldname)), 
+		  PJ_STRING_TO_NATIVE(newname,wnewname,sizeof(wnewname)));
 #endif
 
@@ -160,12 +162,13 @@
 PJ_DEF(pj_status_t) pj_file_getstat(const char *filename, pj_file_stat *stat)
 {
+    PJ_DECL_UNICODE_TEMP_BUF(wfilename,256)
     HANDLE hFile;
     DWORD sizeLo, sizeHi;
     FILETIME creationTime, accessTime, writeTime;
-    PJ_DECL_UNICODE_TEMP_BUF(wfilename,256);
 
     PJ_ASSERT_RETURN(filename!=NULL && stat!=NULL, PJ_EINVAL);
 
-    hFile = CreateFile(PJ_STRING_TO_NATIVE(filename,wfilename), READ_CONTROL, 
+    hFile = CreateFile(PJ_STRING_TO_NATIVE(filename,wfilename,sizeof(wfilename)), 
+		       READ_CONTROL, 
 		       FILE_SHARE_READ, NULL,
                        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
Index: /pjproject/trunk/pjlib/src/pj/file_io_win32.c
===================================================================
--- /pjproject/trunk/pjlib/src/pj/file_io_win32.c	(revision 180)
+++ /pjproject/trunk/pjlib/src/pj/file_io_win32.c	(revision 181)
@@ -45,5 +45,5 @@
                                   pj_oshandle_t *fd)
 {
-    PJ_DECL_UNICODE_TEMP_BUF(wpathname,256);
+    PJ_DECL_UNICODE_TEMP_BUF(wpathname,256)
     HANDLE hFile;
     DWORD dwDesiredAccess = 0;
@@ -79,5 +79,5 @@
     dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL;
 
-    hFile = CreateFile(PJ_STRING_TO_NATIVE(pathname,wpathname), 
+    hFile = CreateFile(PJ_STRING_TO_NATIVE(pathname,wpathname,sizeof(wpathname)), 
 		       dwDesiredAccess, dwShareMode, NULL,
                        dwCreationDisposition, dwFlagsAndAttributes, NULL);
