| 503 | |
| 504 | |
| 505 | bool IntlUtil::initUnicodeCollation(texttype* tt, charset* cs, const ASCII* name, |
| 506 | USHORT attributes, const UCharBuffer& specificAttributes, const string& configInfo) |
| 507 | { |
| 508 | memset(tt, 0, sizeof(*tt)); |
| 509 | |
| 510 | // name comes from stack. Copy it. |
| 511 | ASCII* nameCopy = FB_NEW ASCII[strlen(name) + 1]; |
| 512 | strcpy(nameCopy, name); |
| 513 | tt->texttype_name = nameCopy; |
| 514 | |
| 515 | tt->texttype_version = TEXTTYPE_VERSION_1; |
| 516 | tt->texttype_country = CC_INTL; |
| 517 | tt->texttype_canonical_width = 4; // UTF-32 |
| 518 | tt->texttype_fn_destroy = unicodeDestroy; |
| 519 | tt->texttype_fn_compare = unicodeCompare; |
| 520 | tt->texttype_fn_key_length = unicodeKeyLength; |
| 521 | tt->texttype_fn_string_to_key = unicodeStrToKey; |
| 522 | tt->texttype_fn_canonical = unicodeCanonical; |
| 523 | |
| 524 | IntlUtil::SpecificAttributesMap map; |
| 525 | |
| 526 | Jrd::CharSet* charSet = NULL; |
| 527 | |
| 528 | try |
| 529 | { |
| 530 | charSet = Jrd::CharSet::createInstance(*getDefaultMemoryPool(), 0, cs); |
| 531 | IntlUtil::parseSpecificAttributes(charSet, specificAttributes.getCount(), |
| 532 | specificAttributes.begin(), &map); |
| 533 | delete charSet; |
| 534 | } |
| 535 | catch (...) |
| 536 | { |
| 537 | delete charSet; |
| 538 | gds__log("initUnicodeCollation failed - unexpected exception caught"); |
| 539 | return false; |
| 540 | } |
| 541 | |
| 542 | IntlUtil::SpecificAttributesMap map16; |
| 543 | |
| 544 | SpecificAttributesMap::Accessor accessor(&map); |
| 545 | |
| 546 | bool found = accessor.getFirst(); |
| 547 | |
| 548 | while (found) |
| 549 | { |
| 550 | UCharBuffer s1, s2; |
| 551 | USHORT errCode; |
| 552 | ULONG errPosition; |
| 553 | |
| 554 | s1.resize(cs->charset_to_unicode.csconvert_fn_convert( |
| 555 | &cs->charset_to_unicode, accessor.current()->first.length(), NULL, 0, NULL, &errCode, &errPosition)); |
| 556 | s1.resize(cs->charset_to_unicode.csconvert_fn_convert( |
| 557 | &cs->charset_to_unicode, accessor.current()->first.length(), (UCHAR*) accessor.current()->first.c_str(), |
| 558 | s1.getCapacity(), s1.begin(), &errCode, &errPosition)); |
| 559 | |
| 560 | s2.resize(cs->charset_to_unicode.csconvert_fn_convert( |
| 561 | &cs->charset_to_unicode, accessor.current()->second.length(), NULL, 0, NULL, &errCode, &errPosition)); |
| 562 | s2.resize(cs->charset_to_unicode.csconvert_fn_convert( |
nothing calls this directly
no test coverage detected