diff options
Diffstat (limited to 'sql/sql_string.h')
-rw-r--r-- | sql/sql_string.h | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/sql/sql_string.h b/sql/sql_string.h index d89adb6bf51..518b8e5ba4b 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -43,14 +43,13 @@ inline uint32 copy_and_convert(char *to, uint32 to_length, } -class String_copier: private MY_STRCOPY_STATUS +class String_copier: private MY_STRCONV_STATUS { - const char *m_cannot_convert_error_pos; public: const char *source_end_pos() const - { return m_source_end_pos; } + { return m_native_copy_status.m_source_end_pos; } const char *well_formed_error_pos() const - { return m_well_formed_error_pos; } + { return m_native_copy_status.m_well_formed_error_pos; } const char *cannot_convert_error_pos() const { return m_cannot_convert_error_pos; } const char *most_important_error_pos() const @@ -59,6 +58,17 @@ public: cannot_convert_error_pos(); } /* + Convert a string between character sets. + "dstcs" and "srccs" cannot be &my_charset_bin. + */ + uint convert_fix(CHARSET_INFO *dstcs, char *dst, uint dst_length, + CHARSET_INFO *srccs, const char *src, uint src_length, + uint nchars) + { + return my_convert_fix(dstcs, dst, dst_length, + srccs, src, src_length, nchars, this); + } + /* Copy a string. Fix bad bytes/characters one Unicode conversion, break on bad bytes in case of non-Unicode copying. */ @@ -190,6 +200,7 @@ public: inline bool is_empty() const { return (str_length == 0); } inline void mark_as_const() { Alloced_length= 0;} inline const char *ptr() const { return Ptr; } + inline const char *end() const { return Ptr + str_length; } inline char *c_ptr() { DBUG_ASSERT(!alloced || !Ptr || !Alloced_length || @@ -413,6 +424,17 @@ public: { return copy(str->ptr(), str->length(), str->charset(), tocs, errors); } + bool copy(CHARSET_INFO *tocs, + CHARSET_INFO *fromcs, const char *src, uint32 src_length, + uint32 nchars, String_copier *copier) + { + if (alloc(tocs->mbmaxlen * src_length)) + return true; + str_length= copier->well_formed_copy(tocs, Ptr, Alloced_length, + fromcs, src, src_length, nchars); + str_charset= tocs; + return false; + } void move(String &s) { free(); |