| 135 | } |
| 136 | |
| 137 | wxString Internat::ToDisplayString(double numberToConvert, |
| 138 | int digitsAfterDecimalPoint /* = -1 */) |
| 139 | { |
| 140 | wxString decSep = wxString(GetDecimalSeparator()); |
| 141 | wxString result; |
| 142 | |
| 143 | if (digitsAfterDecimalPoint == -1) |
| 144 | { |
| 145 | result.Printf(wxT("%f"), numberToConvert); |
| 146 | |
| 147 | // Not all libcs respect the decimal separator, so always convert |
| 148 | // any dots found to the decimal separator. |
| 149 | result.Replace(wxT("."), decSep); |
| 150 | |
| 151 | if (result.Find(decSep) != -1) |
| 152 | { |
| 153 | // Strip trailing zeros, but leave one, and decimal separator. |
| 154 | int pos = result.length() - 1; |
| 155 | while ((pos > 1) && |
| 156 | (result.GetChar(pos) == wxT('0')) && |
| 157 | (result.GetChar(pos - 1) != decSep)) |
| 158 | pos--; |
| 159 | // (Previous code removed all of them and decimal separator.) |
| 160 | // if (result.GetChar(pos) == decSep) |
| 161 | // pos--; // strip point before empty fractional part |
| 162 | result = result.Left(pos+1); |
| 163 | } |
| 164 | } |
| 165 | else |
| 166 | { |
| 167 | wxString format; |
| 168 | format.Printf(wxT("%%.%if"), digitsAfterDecimalPoint); |
| 169 | result.Printf(format, numberToConvert); |
| 170 | |
| 171 | // Not all libcs respect the decimal separator, so always convert |
| 172 | // any dots found to the decimal separator |
| 173 | result.Replace(wxT("."), decSep); |
| 174 | } |
| 175 | |
| 176 | return result; |
| 177 | } |
| 178 | |
| 179 | TranslatableString Internat::FormatSize(wxLongLong size) |
| 180 | { |