DELIMITER $;
DROP FUNCTION IF EXISTS `radius`.`fun_split`$
CREATE DEFINER=`root`@`%` FUNCTION `fun_split`(nm varchar(100)) RETURNS varchar(500) CHARSET latin1 READS SQL DATA BEGIN declare i int; declare rtn int; declare rtn1 int; declare sec varchar(10); declare rtnstr varchar(500); set i=1; set rtnstr=''''; WHILE i <length(nm) DO set rtn= ascii(substring(nm,i,1)); IF rtn>127 THEN set rtn1= ascii(right(substring(nm,i,2),1)); IF rtn1> 127 THEN IF i<length(nm)-1 THEN IF (ascii(right(substring(nm,i,3),1))>127 and ascii(right(substring(nm,i,4),1))>127) THEN set sec=concat(right(concat(''00'',rtn-160),2),right(concat(''00'',rtn1-160),2),right(concat(''00'',ascii(right(substring(nm,i,3),1))-160),2),right(concat(''00'',ascii(right(substring(nm,i,4),1))-160),2),'' ''); ELSE set sec=''''; END IF; ELSE set sec=''''; END IF ; ELSE set sec=concat |