mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8240725: Some functions might not work with CJK character
Reviewed-by: naoto
This commit is contained in:
parent
80ca356e7e
commit
99b28daf56
4 changed files with 72 additions and 36 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -101,7 +101,7 @@ static ZFILE
|
|||
ZFILE_Open(const char *fname, int flags) {
|
||||
#ifdef WIN32
|
||||
WCHAR *wfname, *wprefixed_fname;
|
||||
size_t converted_chars, fname_length;
|
||||
size_t fname_length;
|
||||
jlong fhandle;
|
||||
const DWORD access =
|
||||
(flags & O_RDWR) ? (GENERIC_WRITE | GENERIC_READ) :
|
||||
|
@ -135,10 +135,17 @@ ZFILE_Open(const char *fname, int flags) {
|
|||
flagsAndAttributes, /* flags and attributes */
|
||||
NULL);
|
||||
} else {
|
||||
if ((wfname = (WCHAR*)malloc((fname_length + 1) * sizeof(WCHAR))) == NULL)
|
||||
/* Get required buffer size to convert to Unicode */
|
||||
int wfname_len = MultiByteToWideChar(CP_THREAD_ACP, MB_ERR_INVALID_CHARS,
|
||||
fname, -1, NULL, 0);
|
||||
if (wfname_len == 0) {
|
||||
return (jlong)INVALID_HANDLE_VALUE;
|
||||
|
||||
if (mbstowcs_s(&converted_chars, wfname, fname_length + 1, fname, fname_length) != 0) {
|
||||
}
|
||||
if ((wfname = (WCHAR*)malloc(wfname_len * sizeof(WCHAR))) == NULL) {
|
||||
return (jlong)INVALID_HANDLE_VALUE;
|
||||
}
|
||||
if (MultiByteToWideChar(CP_THREAD_ACP, MB_ERR_INVALID_CHARS,
|
||||
fname, -1, wfname, wfname_len) == 0) {
|
||||
free(wfname);
|
||||
return (jlong)INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue