ICU-10038 Add u_fopen variant that accepts UTF16 filename
X-SVN-Rev: 35681
This commit is contained in:
parent
52cf49b10e
commit
3ed1418315
@ -239,6 +239,7 @@
|
|||||||
#define u_flushDefaultConverter U_ICU_ENTRY_POINT_RENAME(u_flushDefaultConverter)
|
#define u_flushDefaultConverter U_ICU_ENTRY_POINT_RENAME(u_flushDefaultConverter)
|
||||||
#define u_foldCase U_ICU_ENTRY_POINT_RENAME(u_foldCase)
|
#define u_foldCase U_ICU_ENTRY_POINT_RENAME(u_foldCase)
|
||||||
#define u_fopen U_ICU_ENTRY_POINT_RENAME(u_fopen)
|
#define u_fopen U_ICU_ENTRY_POINT_RENAME(u_fopen)
|
||||||
|
#define u_fopen_u U_ICU_ENTRY_POINT_RENAME(u_fopen_u)
|
||||||
#define u_forDigit U_ICU_ENTRY_POINT_RENAME(u_forDigit)
|
#define u_forDigit U_ICU_ENTRY_POINT_RENAME(u_forDigit)
|
||||||
#define u_formatMessage U_ICU_ENTRY_POINT_RENAME(u_formatMessage)
|
#define u_formatMessage U_ICU_ENTRY_POINT_RENAME(u_formatMessage)
|
||||||
#define u_formatMessageWithError U_ICU_ENTRY_POINT_RENAME(u_formatMessageWithError)
|
#define u_formatMessageWithError U_ICU_ENTRY_POINT_RENAME(u_formatMessageWithError)
|
||||||
@ -413,6 +414,7 @@
|
|||||||
#define u_vsprintf_u U_ICU_ENTRY_POINT_RENAME(u_vsprintf_u)
|
#define u_vsprintf_u U_ICU_ENTRY_POINT_RENAME(u_vsprintf_u)
|
||||||
#define u_vsscanf U_ICU_ENTRY_POINT_RENAME(u_vsscanf)
|
#define u_vsscanf U_ICU_ENTRY_POINT_RENAME(u_vsscanf)
|
||||||
#define u_vsscanf_u U_ICU_ENTRY_POINT_RENAME(u_vsscanf_u)
|
#define u_vsscanf_u U_ICU_ENTRY_POINT_RENAME(u_vsscanf_u)
|
||||||
|
#define u_wfopen U_ICU_ENTRY_POINT_RENAME(u_wfopen)
|
||||||
#define u_writeIdenticalLevelRun U_ICU_ENTRY_POINT_RENAME(u_writeIdenticalLevelRun)
|
#define u_writeIdenticalLevelRun U_ICU_ENTRY_POINT_RENAME(u_writeIdenticalLevelRun)
|
||||||
#define ubidi_addPropertyStarts U_ICU_ENTRY_POINT_RENAME(ubidi_addPropertyStarts)
|
#define ubidi_addPropertyStarts U_ICU_ENTRY_POINT_RENAME(ubidi_addPropertyStarts)
|
||||||
#define ubidi_close U_ICU_ENTRY_POINT_RENAME(ubidi_close)
|
#define ubidi_close U_ICU_ENTRY_POINT_RENAME(ubidi_close)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998-2013, International Business Machines
|
* Copyright (C) 1998-2014, International Business Machines
|
||||||
* Corporation and others. All Rights Reserved.
|
* Corporation and others. All Rights Reserved.
|
||||||
*
|
*
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
@ -31,6 +31,7 @@
|
|||||||
#include "unicode/uloc.h"
|
#include "unicode/uloc.h"
|
||||||
#include "unicode/ures.h"
|
#include "unicode/ures.h"
|
||||||
#include "unicode/ucnv.h"
|
#include "unicode/ucnv.h"
|
||||||
|
#include "unicode/ustring.h"
|
||||||
#include "cstring.h"
|
#include "cstring.h"
|
||||||
#include "cmemory.h"
|
#include "cmemory.h"
|
||||||
|
|
||||||
@ -147,6 +148,35 @@ u_fopen(const char *filename,
|
|||||||
return result; /* not a file leak */
|
return result; /* not a file leak */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
U_CAPI UFILE* U_EXPORT2
|
||||||
|
u_fopen_u(const UChar *filename,
|
||||||
|
const char *perm,
|
||||||
|
const char *locale,
|
||||||
|
const char *codepage)
|
||||||
|
{
|
||||||
|
UFILE *result;
|
||||||
|
char buffer[256];
|
||||||
|
|
||||||
|
u_austrcpy(buffer, filename);
|
||||||
|
|
||||||
|
result = u_fopen(buffer, perm, locale, codepage);
|
||||||
|
#if U_PLATFORM_USES_ONLY_WIN32_API
|
||||||
|
/* Try Windows API _wfopen if the above fails. */
|
||||||
|
if (!result) {
|
||||||
|
FILE *systemFile = _wfopen(filename, (UChar*)perm);
|
||||||
|
if (systemFile) {
|
||||||
|
result = finit_owner(systemFile, locale, codepage, TRUE);
|
||||||
|
}
|
||||||
|
if (!result) {
|
||||||
|
/* Something bad happened.
|
||||||
|
Maybe the converter couldn't be opened. */
|
||||||
|
fclose(systemFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return result; /* not a file leak */
|
||||||
|
}
|
||||||
|
|
||||||
U_CAPI UFILE* U_EXPORT2
|
U_CAPI UFILE* U_EXPORT2
|
||||||
u_fstropen(UChar *stringBuf,
|
u_fstropen(UChar *stringBuf,
|
||||||
int32_t capacity,
|
int32_t capacity,
|
||||||
|
@ -241,6 +241,29 @@ u_fopen(const char *filename,
|
|||||||
const char *locale,
|
const char *locale,
|
||||||
const char *codepage);
|
const char *codepage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open a UFILE with a UChar* filename
|
||||||
|
* A UFILE is a wrapper around a FILE* that is locale and codepage aware.
|
||||||
|
* That is, data written to a UFILE will be formatted using the conventions
|
||||||
|
* specified by that UFILE's Locale; this data will be in the character set
|
||||||
|
* specified by that UFILE's codepage.
|
||||||
|
* @param filename The name of the file to open.
|
||||||
|
* @param perm The read/write permission for the UFILE; one of "r", "w", "rw"
|
||||||
|
* @param locale The locale whose conventions will be used to format
|
||||||
|
* and parse output. If this parameter is NULL, the default locale will
|
||||||
|
* be used.
|
||||||
|
* @param codepage The codepage in which data will be written to and
|
||||||
|
* read from the file. If this paramter is NULL the system default codepage
|
||||||
|
* will be used.
|
||||||
|
* @return A new UFILE, or NULL if an error occurred.
|
||||||
|
* @draft ICU 54
|
||||||
|
*/
|
||||||
|
U_DRAFT UFILE* U_EXPORT2
|
||||||
|
u_fopen_u(const UChar *filename,
|
||||||
|
const char *perm,
|
||||||
|
const char *locale,
|
||||||
|
const char *codepage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a UFILE on top of an existing FILE* stream. The FILE* stream
|
* Open a UFILE on top of an existing FILE* stream. The FILE* stream
|
||||||
* ownership remains with the caller. To have the UFILE take over
|
* ownership remains with the caller. To have the UFILE take over
|
||||||
|
Loading…
Reference in New Issue
Block a user