| 41 | SDMODE g_stringDecodeMode; |
| 42 | |
| 43 | wxString MakePrintableString(const wxString& s) |
| 44 | { |
| 45 | wxString str = s; |
| 46 | unsigned c = 0; |
| 47 | for (unsigned i = 0; i < str.length(); i++) { |
| 48 | c |= (wxChar) str[i]; |
| 49 | } |
| 50 | |
| 51 | if (c <= 0xff && GetStringsMode() != SD_NONE) { |
| 52 | wxCharBuffer buf = str.To8BitData(); |
| 53 | wxString test = UTF82unicode(buf.data()); |
| 54 | if (!test.empty()) { |
| 55 | str = test; |
| 56 | c = 0; |
| 57 | for (unsigned i = 0; i < str.length(); i++) { |
| 58 | c |= (wxChar) str[i]; |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | wxString retval = "\""; |
| 64 | |
| 65 | if (GetStringsMode() == SD_DISPLAY) { |
| 66 | retval += str; |
| 67 | } else if (GetStringsMode() == SD_UTF8) { |
| 68 | str = wxString::From8BitData((const char *)str.utf8_str()); |
| 69 | c = 0xff; |
| 70 | } |
| 71 | |
| 72 | if (GetStringsMode() != SD_DISPLAY) { |
| 73 | for (unsigned i = 0; i < str.length(); i++) { |
| 74 | if (GetStringsMode() == SD_NONE ? ((unsigned)str[i] >= ' ' && (unsigned)str[i] <= 0x7f) : std::isprint(str[i])) { |
| 75 | retval += str[i]; |
| 76 | } else if (c <= 0xff) { |
| 77 | retval += wxString::Format("\\x%02x", str[i]); |
| 78 | } else { |
| 79 | retval += wxString::Format("\\u%04x", str[i]); |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | retval += "\""; |
| 85 | return retval; |
| 86 | } |
| 87 | |
| 88 | std::ostream& operator<<(std::ostream& x, const CTimeT& y) |
| 89 | { |
no test coverage detected