summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwtchang%redhat.com <devnull@localhost>2006-07-14 22:17:28 +0000
committerwtchang%redhat.com <devnull@localhost>2006-07-14 22:17:28 +0000
commit3c54a0392fa52d957183368ca43b602945e06311 (patch)
tree2acc64daa910149e29811c6114f8455f4230cdfa
parentfc594cb0a012b076c56fbb1b91df0ac1f55782df (diff)
downloadnspr-hg-3c54a0392fa52d957183368ca43b602945e06311.tar.gz
Bugzilla Bug 326168: Windows NT 3.51 doesn't support CP_UTF8 either, so
having Unicode support doesn't imply having CP_UTF8 support. The patch is contributed by neil@parkwaycc.co.uk <neil@httl.net>. r=wtc. Tag: NSPR_4_6_BRANCH
-rw-r--r--pr/src/linking/prlink.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/pr/src/linking/prlink.c b/pr/src/linking/prlink.c
index 51bff2b8..7fb06b78 100644
--- a/pr/src/linking/prlink.c
+++ b/pr/src/linking/prlink.c
@@ -1160,11 +1160,15 @@ static int pr_ConvertUTF16toUTF8(LPCWSTR wname, LPSTR name, int len)
int utf8Len = 0;
PRBool highSurrogate = PR_FALSE;
- /* Windows NT4/2k/XP supports CP_UTF8. So do Win 98/ME, but
- * we don't bother to optimize for them. */
- if (_pr_useUnicode)
- return WideCharToMultiByte(CP_UTF8, 0, wname, -1, name, len,
- NULL, NULL);
+ utf8Len = WideCharToMultiByte(CP_UTF8, 0, wname, -1, name, len,
+ NULL, NULL);
+ /*
+ * Windows 95 and NT 3.51 don't support CP_UTF8.
+ * WideCharToMultiByte(CP_UTF8, ...) fails with the error code
+ * ERROR_INVALID_PARAMETER on Windows 95 and NT 3.51.
+ */
+ if (utf8Len || GetLastError() != ERROR_INVALID_PARAMETER)
+ return utf8Len;
if (!wname || len < 0 || (len > 0 && !name)) {
SetLastError(ERROR_INVALID_PARAMETER);