26#include <wx/filename.h>
48 const wxString& str2 = wxGetTranslation( str1 );
56 struct lconv * localeInfo = localeconv();
58 mDecimalSeparator = wxString(wxSafeConvertMB2WX(localeInfo->decimal_point)).GetChar(0);
65 wxPathFormat
format = wxPATH_MAC;
66#elif defined(__WXGTK__)
67 wxPathFormat
format = wxPATH_UNIX;
68#elif defined(__WXMSW__)
69 wxPathFormat
format = wxPATH_WIN;
74 auto forbid = wxFileName::GetForbiddenChars(
format);
76 for (
auto cc: forbid) {
78 if (cc ==
wxT(
'*') || cc ==
wxT(
'?')) {
82 exclude.push_back(wxString{ cc });
89 auto separators = wxString(
"\\/");
91 for(
auto cc: separators) {
92 if (forbid.Find(cc) == wxNOT_FOUND)
93 exclude.push_back(wxString{ cc });
99 wxSetlocale( LC_NUMERIC,
"C" );
112 wxString s = stringToConvert;
114 s.Replace(
wxT(
","),
wxT(
"."));
116 return s.ToCDouble(result);
127 int digitsAfterDecimalPoint )
130 numberToConvert, digitsAfterDecimalPoint);
138 int digitsAfterDecimalPoint )
143 if (digitsAfterDecimalPoint == -1)
145 result.Printf(
wxT(
"%f"), numberToConvert);
149 result.Replace(
wxT(
"."), decSep);
151 if (result.Find(decSep) != -1)
154 int pos = result.length() - 1;
156 (result.GetChar(pos) ==
wxT(
'0')) &&
157 (result.GetChar(pos - 1) != decSep))
162 result = result.Left(pos+1);
168 format.Printf(
wxT(
"%%.%if"), digitsAfterDecimalPoint);
169 result.Printf(
format, numberToConvert);
173 result.Replace(
wxT(
"."), decSep);
182 double dSize =
size.GetHi() * pow(2.0, 32);
183 dSize +=
size.GetLo();
193 sizeStr =
XO(
"Unable to determine");
198 else if (
size < 1024.0 * 1024.0) {
202 else if (
size < 1024.0 * 1024.0 * 1024.0) {
218 for(
const auto &item :
exclude)
220 if(
name.Contains(item))
222 name.Replace(item, sub);
STRINGS_API const wxString & GetCustomTranslation(const wxString &str1)
STRINGS_API const wxString & GetCustomSubstitution(const wxString &str1)
static wxChar GetDecimalSeparator()
Get the decimal separator for the current locale.
static wxString ToDisplayString(double numberToConvert, int digitsAfterDecimalPoint=-1)
Convert a number to a string, uses the user's locale's decimal separator.
static wxString ToString(double numberToConvert, int digitsAfterDecimalPoint=-1)
Convert a number to a string, always uses the dot as decimal separator.
static wxChar mDecimalSeparator
static TranslatableString FormatSize(wxLongLong size)
Convert a number to a string while formatting it in bytes, KB, MB, GB.
static void Init()
Initialize internationalisation support. Call this once at program start.
static bool SanitiseFilename(wxString &name, const wxString &sub)
Check a proposed file name string for illegal characters and remove them return true iff name is "vis...
static void SetCeeNumberFormat()
static bool CompatibleToDouble(const wxString &stringToConvert, double *result)
Convert a string to a number.
static wxArrayString exclude
Holds a msgid for the translation catalog; may also bind format arguments.