Skip to content

Instantly share code, notes, and snippets.

@pv8
pv8 / initcap2_pg.sql
Created January 6, 2014 23:04
Alternative function to PostgreSQL builtin initcap(text) with support for accented words.
-- ========================================================================
-- Function: initcap2(text)
-- Return Type: text
-- Description: Alternative function to builtin initcap(text). This function
-- convert the first letter of each word to upper case and
-- the rest to lower case EVEN IF the sentence has accented words.
-- Example: initcap2('welcome to CHAMPS-ÉLYSÉES')
-- Result: 'Welcome To Champs-Élysées'
--
-- License: MIT