mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 09:19:01 +00:00
Create fopen wrapper that internally uses wide characters under Windows, issue #261
This commit is contained in:
parent
e22507ed1f
commit
667ddd1989
2 changed files with 15 additions and 0 deletions
|
@ -282,6 +282,13 @@ inline sint nlstricmp(const std::string &lhs, const std::string &rhs) { return s
|
||||||
inline sint nlstricmp(const std::string &lhs, const char *rhs) { return stricmp(lhs.c_str(),rhs); }
|
inline sint nlstricmp(const std::string &lhs, const char *rhs) { return stricmp(lhs.c_str(),rhs); }
|
||||||
inline sint nlstricmp(const char *lhs, const std::string &rhs) { return stricmp(lhs,rhs.c_str()); }
|
inline sint nlstricmp(const char *lhs, const std::string &rhs) { return stricmp(lhs,rhs.c_str()); }
|
||||||
|
|
||||||
|
// macros helper to convert UTF-8 std::string and wchar_t*
|
||||||
|
#define wideToUtf8(str) (ucstring((ucchar*)str).toUtf8())
|
||||||
|
#define utf8ToWide(str) ((wchar_t*)ucstring::makeFromUtf8(str).c_str())
|
||||||
|
|
||||||
|
// wrapper for fopen to be able to open files with an UTF-8 filename
|
||||||
|
FILE* nlfopen(const std::string &filename, const std::string &mode);
|
||||||
|
|
||||||
/** Signed 64 bit fseek. Same interface as fseek
|
/** Signed 64 bit fseek. Same interface as fseek
|
||||||
*/
|
*/
|
||||||
int nlfseek64( FILE *stream, sint64 offset, int origin );
|
int nlfseek64( FILE *stream, sint64 offset, int origin );
|
||||||
|
|
|
@ -1099,6 +1099,14 @@ void displayDwordBits( uint32 b, uint nbits, sint beginpos, bool displayBegin, N
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FILE* nlfopen(const std::string &filename, const std::string &mode)
|
||||||
|
{
|
||||||
|
#ifdef NL_OS_WINDOWS
|
||||||
|
return _wfopen(utf8ToWide(filename), utf8ToWide(mode));
|
||||||
|
#else
|
||||||
|
return fopen(filename.c_str(), mode.c_str());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int nlfseek64( FILE *stream, sint64 offset, int origin )
|
int nlfseek64( FILE *stream, sint64 offset, int origin )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue