I have mysql function that capitalizes the first letter of each word in desired string.
What I want to do is to convert Turkish characters to Turkish occurence instead of English occurence such as;
i = I (should be İ), ş = S (should be Ş) etc.
Correct conversion table;
i = İ (currently : I)
ö = Ö (currently : O)
ü = Ü (currently : U)
ç = Ç (currently : C)
ş = Ş (currently : S)
I tested with both utf8
and utf8_turkish_ci
encoding but same result.
Used function is;
CREATE FUNCTION CAP_FIRST (input VARCHAR(255))
RETURNS VARCHAR(255)
DETERMINISTIC
BEGIN
DECLARE len INT;
DECLARE i INT;
SET len = CHAR_LENGTH(input);
SET input = LOWER(input);
SET i = 0;
WHILE (i < len) DO
IF (MID(input,i,1) = ' ' OR i = 0) THEN
IF (i < len) THEN
SET input = CONCAT(
LEFT(input,i),
UPPER(MID(input,i + 1,1)),
RIGHT(input,len - i - 1)
);
END IF;
END IF;
SET i = i + 1;
END WHILE;
RETURN input;
END;
How could I solve this issue with pure mysql function?