Cleaning up unicode conversion

This commit is contained in:
kaetemi 2019-05-01 11:52:03 +08:00
parent b59efe8ff0
commit 83fdb7b4a1
3 changed files with 11 additions and 4 deletions

View file

@ -357,9 +357,6 @@ inline tstring mbcsToTStr(const std::string &str) { return (const tstring &)str;
#define nlMbcsToTStr(str) ((const tchar *)NLMISC::asCStr(str))
#endif
inline const tchar *asCStr(const tchar *str) { return str; }
inline const tchar *asCStr(const tstring &str) { return str.c_str(); }
} // NLMISC
#endif // NL_STRING_COMMON_H

View file

@ -146,7 +146,7 @@ int nltmain(int argc, const NLMISC::tchar **argv) \
{ \
NLMISC::CApplicationContext serviceContext; \
__ServiceClassName *scn = new __ServiceClassName; \
scn->setArgs (argc, nlTStrToUtf8(argv)); \
scn->setArgs (argc, argv); \
createDebug(NULL,!scn->haveLongArg("nolog"));\
scn->setCallbackArray (__ServiceCallbackArray, sizeof(__ServiceCallbackArray)/sizeof(__ServiceCallbackArray[0])); \
sint retval = scn->main (__ServiceShortName, __ServiceLongName, __ServicePort, __ConfigDir, __LogDir, __DATE__ " " __TIME__); \
@ -350,6 +350,9 @@ public:
/// Sets the command line and init _Args variable. You must call this before calling main()
void setArgs (int argc, const char **argv);
/// Sets the command line and init _Args variable. You must call this before calling main()
void setArgs (int argc, const wchar_t **argv);
/// Sets the command line and init _Args variable. You must call this before calling main()
void setArgs (const char *args);

View file

@ -492,6 +492,13 @@ void IService::setArgs (int argc, const char **argv)
}
}
void IService::setArgs(int argc, const wchar_t **argv)
{
for (sint i = 0; i < argc; i++)
{
_Args.push_back(nlWideToUtf8(argv[i]));
}
}
void cbLogFilter (CConfigFile::CVar &var)
{