| 779 | |
| 780 | |
| 781 | void 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 && |
no test coverage detected