514
514
****************************************************************************/
519
Copy string with HEX-encoding of "bad" characters.
521
@details This functions copies the string pointed by "src"
522
to the string pointed by "dst". Not more than "srclen" bytes
523
are read from "src". Any sequences of bytes representing
524
a not-well-formed substring (according to cs) are hex-encoded,
525
and all well-formed substrings (according to cs) are copied as is.
526
Not more than "dstlen" bytes are written to "dst". The number
527
of bytes written to "dst" is returned.
529
@param cs character set pointer of the destination string
530
@param[out] dst destination string
531
@param dstlen size of dst
532
@param src source string
533
@param srclen length of src
535
@retval result length
539
my_copy_with_hex_escaping(const CHARSET_INFO * const cs,
540
char *dst, size_t dstlen,
541
const char *src, size_t srclen)
543
const char *srcend= src + srclen;
546
for ( ; src < srcend ; )
549
if ((chlen= my_ismbchar(cs, src, srcend)))
553
memcpy(dst, src, chlen);
558
else if (*src & 0x80)
564
*dst++= _dig_vec_upper[((unsigned char) *src) >> 4];
565
*dst++= _dig_vec_upper[((unsigned char) *src) & 15];
582
518
with optional character set conversion,