MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / convertToUTF8

Method convertToUTF8

src/jrd/DataTypeUtil.cpp:366–403  ·  view source on GitHub ↗

Returns false if conversion is not needed.

Source from the content-addressed store, hash-verified

364
365// Returns false if conversion is not needed.
366bool DataTypeUtil::convertToUTF8(const string& src, string& dst, CHARSET_ID charset, ErrorFunction err)
367{
368 thread_db* tdbb = JRD_get_thread_data();
369
370 if (charset == CS_dynamic)
371 {
372 fb_assert(tdbb->getAttachment());
373 charset = tdbb->getAttachment()->att_charset;
374 }
375
376 if (charset == CS_UTF8 || charset == CS_UNICODE_FSS)
377 return false;
378
379 if (charset == CS_NONE)
380 {
381 const FB_SIZE_T length = src.length();
382
383 const char* s = src.c_str();
384 char* p = dst.getBuffer(length);
385
386 for (const char* end = src.end(); s < end; ++p, ++s)
387 *p = (*s < 0 ? '?' : *s);
388 }
389 else // charset != CS_UTF8
390 {
391 DataTypeUtil dtUtil(tdbb);
392 ULONG length = dtUtil.convertLength(src.length(), charset, CS_UTF8);
393
394 length = INTL_convert_bytes(tdbb,
395 CS_UTF8, (UCHAR*) dst.getBuffer(length), length,
396 charset, (const BYTE*) src.begin(), src.length(),
397 err);
398
399 dst.resize(length);
400 }
401
402 return true;
403}
404
405} // namespace Jrd

Callers

nothing calls this directly

Calls 10

JRD_get_thread_dataFunction · 0.85
INTL_convert_bytesFunction · 0.85
getAttachmentMethod · 0.45
lengthMethod · 0.45
c_strMethod · 0.45
getBufferMethod · 0.45
endMethod · 0.45
convertLengthMethod · 0.45
beginMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected