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

Method canonical

src/common/TextType.cpp:354–388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

352
353
354ULONG TextType::canonical(ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst)
355{
356 if (tt->texttype_fn_canonical)
357 return (*tt->texttype_fn_canonical)(tt, srcLen, src, dstLen, dst);
358
359 if (getCharSet()->isMultiByte())
360 {
361 fb_assert(tt->texttype_canonical_width == sizeof(ULONG));
362
363 Firebird::HalfStaticArray<UCHAR, BUFFER_SMALL> utf16_str;
364
365 ULONG utf16_len = getCharSet()->getConvToUnicode().convertLength(srcLen);
366
367 ULONG errPos;
368
369 // convert to UTF-16
370 utf16_len = getCharSet()->getConvToUnicode().convert(srcLen, src,
371 utf16_len, utf16_str.getBuffer(utf16_len), &errPos);
372
373 USHORT errCode;
374
375 // convert UTF-16 to UTF-32
376 return UnicodeUtil::utf16ToUtf32(utf16_len, Firebird::Aligner<USHORT>(utf16_str.begin(), utf16_len),
377 dstLen, Firebird::OutAligner<ULONG>(dst, dstLen), &errCode, &errPos) / sizeof(ULONG);
378 }
379
380 fb_assert(
381 (tt->texttype_canonical_width == 0 && !tt->texttype_fn_canonical) ||
382 tt->texttype_canonical_width == getCharSet()->minBytesPerChar());
383 fb_assert(dstLen >= srcLen);
384
385 memcpy(dst, src, srcLen);
386
387 return srcLen / getCharSet()->minBytesPerChar();
388}
389
390BYTE TextType::getCanonicalWidth() const
391{

Callers 6

executeMethod · 0.45
evlPositionFunction · 0.45
evlReplaceFunction · 0.45
CanonicalConverterMethod · 0.45
optimizeLikeSimilarMethod · 0.45
unicodeCanonicalFunction · 0.45

Calls 7

isMultiByteMethod · 0.80
getConvToUnicodeMethod · 0.80
minBytesPerCharMethod · 0.80
convertLengthMethod · 0.45
convertMethod · 0.45
getBufferMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected