mysql - SPLIT_STR not working with the foreign languages -
i got function split_str blog.fedecarg.com
here code
create function split_str( x varchar(255), delim varchar(12), pos int ) returns varchar(255) return replace(substring(substring_index(x, delim, pos), length(substring_index(x, delim, pos -1)) + 1), delim, ''); if try select like
select split_str('accountname;โอมtest;no.454646;i;2013-8-23', ';' , 2) 'res'; the result is
_________________ | res | | ------------- | | โอมtest | _________________ if change index 3
select split_str('accountname;โอมtest;no.454646;i;2013-8-23', ';' , 3) 'res'; the expected value no.454646
but result is
_________________ | res | | ------------- | | 4646 | _________________ is function split_str has bug?
note : if cut foreign languages(โอม) out. problem solved.
how can use function working foreign languages, please help.
thanks.
length returns string length in bytes; foreign language characters 2 or 3 bytes utf sequences. try replace length char_lenght, returns length of string measured in characters, in function definition.
sqlfiddle: http://sqlfiddle.com/#!2/1bb2d/1
Comments
Post a Comment