Last active
September 4, 2015 13:45
-
-
Save chanmix51/331987 to your computer and use it in GitHub Desktop.
transliteration in plpgsql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION transliterate(my_text VARCHAR) RETURNS varchar AS $$ | |
DECLARE | |
text_out VARCHAR DEFAULT ''; | |
BEGIN | |
text_out := my_text; | |
text_out := translate(text_out, 'áàâäåáăąãāçċćčĉéèėëêēĕîïìíīñôöøõōùúüûūýÿỳ', 'aaaaaaaaaaccccceeeeeeeiiiiinooooouuuuuyyy'); | |
text_out := translate(text_out, 'ÁÀÂÄÅÁĂĄÃĀÇĊĆČĈÉÈĖËÊĒĔÎÏÌÍĪÑÔÖØÕŌÙÚÜÛŪÝŸỲ', 'AAAAAAAAAACCCCCEEEEEEEIIIIINOOOOOUUUUUYYY'); | |
text_out := replace(text_out, 'æ', 'ae'); | |
text_out := replace(text_out, 'Œ', 'OE'); | |
text_out := replace(text_out, 'Æ', 'AE'); | |
text_out := replace(text_out, 'ß', 'ss'); | |
text_out := replace(text_out, 'œ', 'oe'); | |
RETURN text_out; | |
END; | |
$$ LANGUAGE plpgsql IMMUTABLE; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment