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

Method ReadOnlyString

src/SafeFile.cpp:234–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232
233
234wxString CFileDataIO::ReadOnlyString(bool bOptUTF8, uint16 raw_len) const
235{
236 // We only need to set the the NULL terminator, since we know that
237 // reads will either succeed or throw an exception, in which case
238 // we wont be returning anything
239 std::vector<char> val_array(raw_len + 1);
240 val_array[raw_len] = 0;
241
242 char* val = &(val_array[0]);
243
244 Read(val, raw_len);
245 wxString str;
246
247 if (CHECK_BOM(raw_len, val)) {
248 // This is a UTF8 string with a BOM header, skip header.
249 str = UTF82unicode(val + 3);
250 } else if (bOptUTF8) {
251 str = UTF82unicode(val);
252 if (str.IsEmpty()) {
253 // Fallback to Latin-1
254 str = wxString(val, wxConvISO8859_1, raw_len);
255 }
256 } else {
257 // Raw strings are written as Latin-1 (see CFileDataIO::WriteStringCore)
258 str = wxString(val, wxConvISO8859_1, raw_len);
259 }
260
261 return str;
262}
263
264
265void CFileDataIO::WriteUInt8(uint8 value)

Callers 2

ProcessPacketMethod · 0.80
CTagMethod · 0.80

Calls 3

UTF82unicodeFunction · 0.85
wxStringClass · 0.70
IsEmptyMethod · 0.45

Tested by

no test coverage detected