MCPcopy Create free account
hub / github.com/amule-project/amule / MakePrintableString

Function MakePrintableString

src/utils/fileview/Print.cpp:43–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41SDMODE g_stringDecodeMode;
42
43wxString 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
88std::ostream& operator<<(std::ostream& x, const CTimeT& y)
89{

Callers 2

Print.cppFile · 0.85
DecodeKeyIndexDatFunction · 0.85

Calls 3

GetStringsModeFunction · 0.85
UTF82unicodeFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected