83
char *sql_strmake_with_convert(const char *str, size_t arg_length,
84
const CHARSET_INFO * const from_cs,
85
size_t max_res_length,
86
const CHARSET_INFO * const to_cs,
87
size_t *result_length)
90
size_t new_length= to_cs->mbmaxlen*arg_length;
91
max_res_length--; // Reserve place for end null
93
set_if_smaller(new_length, max_res_length);
94
if (!(pos= (char*) sql_alloc(new_length+1)))
97
if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin))
99
// Safety if to_cs->mbmaxlen > 0
100
new_length= cmin(arg_length, max_res_length);
101
memcpy(pos, str, new_length);
105
uint32_t dummy_errors;
106
new_length= copy_and_convert((char*) pos, new_length, to_cs, str,
107
arg_length, from_cs, &dummy_errors);
110
*result_length= new_length;