How to encode accents in an ascii sql file

Sometimes when you want to send a sql file to someone and it contains accents things go … bad.
To circumvent this in oracle sql files you can escape these with compose(unistr(‘CHARACTER + ACCENT’)).
This way your sql file remains ascii encoded and accents don’t go the way of the dodo.

-- The most common combining characters in ANSI are:
-- U+0300: grave accent (`)
-- U+0301: acute accent (´)
-- U+0302: circumflex accent(^)
-- U+0303: tilde (~)
-- U+0308: umlaut (¨)

SELECT
compose(unistr('a\0300')) as "grave accent",
compose(unistr('a\0301')) as "acute accent",
compose(unistr('a\0302')) as "circumflex accent",
compose(unistr('a\0303')) as "tilde",
compose(unistr('a\0308')) as "umlaut"
FROM DUAL;

Leave a Reply