| 352 | |
| 353 | |
| 354 | ULONG 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 | |
| 390 | BYTE TextType::getCanonicalWidth() const |
| 391 | { |
no test coverage detected