diff options
author | Alexander Barkov <bar@mariadb.org> | 2013-08-01 17:03:15 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2013-08-01 17:03:15 +0400 |
commit | 240445660844a4f641c91c147bde18df27733f2f (patch) | |
tree | 213956cd17831da4137ae1647435caee3adbcff3 /mysys/string.c | |
parent | 5f6380adde2dac3f32b40339b9b702c0135eb7d6 (diff) | |
download | mariadb-git-240445660844a4f641c91c147bde18df27733f2f.tar.gz |
Merging my_convert() from 10.0-serg
modified:
include/m_ctype.h
mysys/ma_dyncol.c
mysys/string.c
sql/sql_string.cc
sql/sql_string.h
strings/ctype.c
Diffstat (limited to 'mysys/string.c')
-rw-r--r-- | mysys/string.c | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/mysys/string.c b/mysys/string.c index 1263e7824f9..42fe83ed4e1 100644 --- a/mysys/string.c +++ b/mysys/string.c @@ -223,77 +223,3 @@ void dynstr_reassociate(DYNAMIC_STRING *str, char **ptr, size_t *length, *alloc_length= str->max_length; str->str=0; } - - -/* - copy a string from one character set to another - - SYNOPSIS - copy_and_convert() - to Store result here - to_cs Character set of result string - from Copy from here - from_length Length of from string - from_cs From character set - - NOTES - 'to' must be big enough as form_length * to_cs->mbmaxlen - - RETURN - length of bytes copied to 'to' -*/ - -uint32 -copy_and_convert_extended(char *to, uint32 to_length, CHARSET_INFO *to_cs, - const char *from, uint32 from_length, - CHARSET_INFO *from_cs, - uint *errors) -{ - int cnvres; - my_wc_t wc; - const uchar *from_end= (const uchar*) from+from_length; - char *to_start= to; - uchar *to_end= (uchar*) to+to_length; - my_charset_conv_mb_wc mb_wc= from_cs->cset->mb_wc; - my_charset_conv_wc_mb wc_mb= to_cs->cset->wc_mb; - uint error_count= 0; - - while (1) - { - if ((cnvres= (*mb_wc)(from_cs, &wc, (uchar*) from, - from_end)) > 0) - from+= cnvres; - else if (cnvres == MY_CS_ILSEQ) - { - error_count++; - from++; - wc= '?'; - } - else if (cnvres > MY_CS_TOOSMALL) - { - /* - A correct multibyte sequence detected - But it doesn't have Unicode mapping. - */ - error_count++; - from+= (-cnvres); - wc= '?'; - } - else - break; // Not enough characters - -outp: - if ((cnvres= (*wc_mb)(to_cs, wc, (uchar*) to, to_end)) > 0) - to+= cnvres; - else if (cnvres == MY_CS_ILUNI && wc != '?') - { - error_count++; - wc= '?'; - goto outp; - } - else - break; - } - *errors= error_count; - return (uint32) (to - to_start); -} |