#include "rar.hpp" const char *NullToEmpty(const char *Str) { … } const wchar *NullToEmpty(const wchar *Str) { … } void IntToExt(const std::string &Src,std::string &Dest) { … } // Convert archived names and comments to Unicode. // Allows user to select a code page in GUI. void ArcCharToWide(const char *Src,std::wstring &Dest,ACTW_ENCODING Encoding) { … } int stricomp(const char *s1,const char *s2) { … } int strnicomp(const char *s1,const char *s2,size_t n) { … } wchar* RemoveEOL(wchar *Str) { … } void RemoveEOL(std::wstring &Str) { … } wchar* RemoveLF(wchar *Str) { … } void RemoveLF(std::wstring &Str) { … } #if defined(SFX_MODULE) // char version of etoupperw. Used in console SFX module only. // Fast toupper for English only input and output. Additionally to speed, // it also avoids Turkish small i to big I with dot conversion problem. // We do not define 'c' as 'int' to avoid necessity to cast all // signed chars passed to this function to unsigned char. unsigned char etoupper(unsigned char c) { return c>='a' && c<='z' ? c-'a'+'A' : c; } #endif // Fast toupper for English only input and output. Additionally to speed, // it also avoids Turkish small i to big I with dot conversion problem. // We do not define 'c' as 'int' to avoid necessity to cast all // signed wchars passed to this function to unsigned char. wchar etoupperw(wchar c) { … } // We do not want to cast every signed char to unsigned when passing to // isdigit, so we implement the replacement. Shall work for Unicode too. // If chars are signed, conversion from char to int could generate negative // values, resulting in undefined behavior in standard isdigit. bool IsDigit(int ch) { … } // We do not want to cast every signed char to unsigned when passing to // isspace, so we implement the replacement. Shall work for Unicode too. // If chars are signed, conversion from char to int could generate negative // values, resulting in undefined behavior in standard isspace. bool IsSpace(int ch) { … } // We do not want to cast every signed char to unsigned when passing to // isalpha, so we implement the replacement. Shall work for Unicode too. // If chars are signed, conversion from char to int could generate negative // values, resulting in undefined behavior in standard function. bool IsAlpha(int ch) { … } void BinToHex(const byte *Bin,size_t BinSize,std::wstring &Hex) { … } #ifndef SFX_MODULE uint GetDigits(uint Number) { … } #endif bool LowAscii(const std::string &Str) { … } bool LowAscii(const std::wstring &Str) { … } int wcsicompc(const wchar *s1,const wchar *s2) // For path comparison. { … } int wcsicompc(const std::wstring &s1,const std::wstring &s2) { … } int wcsnicompc(const wchar *s1,const wchar *s2,size_t n) { … } int wcsnicompc(const std::wstring &s1,const std::wstring &s2,size_t n) { … } // Safe copy: copies maxlen-1 max and for maxlen>0 returns zero terminated dest. void strncpyz(char *dest, const char *src, size_t maxlen) { … } // Safe copy: copies maxlen-1 max and for maxlen>0 returns zero terminated dest. void wcsncpyz(wchar *dest, const wchar *src, size_t maxlen) { … } // Safe append: resulting dest length cannot exceed maxlen and dest // is always zero terminated. 'maxlen' parameter defines the entire // dest buffer size and is not compatible with wcsncat. void strncatz(char* dest, const char* src, size_t maxlen) { … } // Safe append: resulting dest length cannot exceed maxlen and dest // is always zero terminated. 'maxlen' parameter defines the entire // dest buffer size and is not compatible with wcsncat. void wcsncatz(wchar* dest, const wchar* src, size_t maxlen) { … } void itoa(int64 n,char *Str,size_t MaxSize) { … } void itoa(int64 n,wchar *Str,size_t MaxSize) { … } // Convert the number to string using thousand separators. void fmtitoa(int64 n,wchar *Str,size_t MaxSize) { … } std::wstring GetWide(const char *Src) { … } // Parse string containing parameters separated with spaces. // Support quote marks. Accepts and updates the current position in the string. // Returns false if there is nothing to parse. bool GetCmdParam(const std::wstring &CmdLine,std::wstring::size_type &Pos,std::wstring &Param) { … } #ifndef RARDLL // For compatibility with existing translations we use %s to print Unicode // strings in format strings and convert them to %ls here. %s could work // without such conversion in Windows, but not in Unix wprintf. void PrintfPrepareFmt(const wchar *Org,std::wstring &Cvt) { … } // Print output to std::wstring. std::wstring wstrprintf(const wchar *fmt,...) { … } std::wstring vwstrprintf(const wchar *fmt,va_list arglist) { … } #endif #ifdef _WIN_ALL bool ExpandEnvironmentStr(std::wstring &Str) { DWORD ExpCode=ExpandEnvironmentStrings(Str.c_str(),nullptr,0); if (ExpCode==0) return false; std::vector<wchar> Buf(ExpCode); ExpCode=ExpandEnvironmentStrings(Str.c_str(),Buf.data(),(DWORD)Buf.size()); if (ExpCode==0 || ExpCode>Buf.size()) return false; Str=Buf.data(); return true; } #endif void TruncateAtZero(std::wstring &Str) { … } void ReplaceEsc(std::wstring &Str) { … }