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

Function INTL_convert_string

src/jrd/intl.cpp:781–901  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

779
780
781void INTL_convert_string(dsc* to, const dsc* from, Firebird::Callbacks* cb)
782{
783/**************************************
784 *
785 * I N T L _ c o n v e r t _ s t r i n g
786 *
787 **************************************
788 *
789 * Functional description
790 * Convert a string from one type to another
791 *
792 **************************************/
793
794 const auto tdbb = JRD_get_thread_data();
795
796 fb_assert(to != NULL);
797 fb_assert(from != NULL);
798 fb_assert(IS_TEXT(to) && IS_TEXT(from));
799
800 const CHARSET_ID from_cs = INTL_charset(tdbb, INTL_TTYPE(from));
801 const CHARSET_ID to_cs = INTL_charset(tdbb, INTL_TTYPE(to));
802
803 UCHAR* p = to->dsc_address;
804
805 // Must convert dtype(cstring,text,vary) and ttype(ascii,binary,..intl..)
806
807 UCHAR* from_ptr;
808 USHORT from_type;
809 const USHORT from_len = CVT_get_string_ptr(from, &from_type, &from_ptr, NULL, 0,
810 tdbb->getAttachment()->att_dec_status, cb->err);
811
812 const ULONG to_size = TEXT_LEN(to);
813
814 const UCHAR* q = from_ptr;
815 CharSet* const toCharSet = INTL_charset_lookup(tdbb, to_cs);
816
817 UCHAR* const to_ptr = to->dsc_dtype == dtype_varying ?
818 reinterpret_cast<UCHAR*>(((vary*) p)->vary_string) :
819 p;
820
821 ULONG to_fill;
822
823 if (from_cs != to_cs && to_cs != CS_BINARY && to_cs != CS_NONE && from_cs != CS_NONE)
824 {
825 ULONG to_len;
826
827 try
828 {
829 to_len = INTL_convert_bytes(tdbb, to_cs, to_ptr, to_size, from_cs, from_ptr, from_len, cb->err);
830 }
831 catch (const status_exception& e)
832 {
833 const auto status = e.value();
834
835 if (status[0] == isc_arg_gds &&
836 status[1] == isc_arith_except &&
837 status[2] == isc_arg_gds &&
838 status[3] == isc_string_truncation &&

Callers 1

transliterateMethod · 0.85

Calls 13

JRD_get_thread_dataFunction · 0.85
INTL_charsetFunction · 0.85
TEXT_LENFunction · 0.85
INTL_charset_lookupFunction · 0.85
INTL_convert_bytesFunction · 0.85
GdsClass · 0.85
pad_spacesFunction · 0.85
wellFormedMethod · 0.80
CVT_get_string_ptrFunction · 0.70
getAttachmentMethod · 0.45
valueMethod · 0.45
validateLengthMethod · 0.45

Tested by

no test coverage detected