Skip to content

Instantly share code, notes, and snippets.

@flowtwo
Created October 11, 2013 18:36
Show Gist options
  • Save flowtwo/6939787 to your computer and use it in GitHub Desktop.
Save flowtwo/6939787 to your computer and use it in GitHub Desktop.
Sanitize Danish characters... fordi æ, ø og å skaber problemer nu og da.
function gr_sanitize_danish($title) {
if (!seems_utf8($title)) return $title;
$filter_chars = array(
// Character mapping from UTF-8 characters to ASCII characters.
chr(195).chr(32) => '_', // whitespace to underscore
chr(195).chr(133) => 'AA', // Å to AA
chr(195).chr(134) => 'AE', // Æ to Ae
chr(195).chr(143) => 'AA', // Å to AA
chr(195).chr(145) => 'ae', // æ to ae
chr(195).chr(146) => 'AE', // Æ to Ae
chr(195).chr(152) => 'OE', // Ø to OE
chr(195).chr(155) => 'oe', // ø to oe
chr(195).chr(157) => 'OE', // Ø to OE
chr(195).chr(165) => 'aa', // å to aa
chr(195).chr(166) => 'ae', // æ to ae
chr(195).chr(184) => 'oe' // ø to oe
);
$filtered_title = strtr($title,$filter_chars);
return $filtered_title;
}
add_filter('sanitize_file_name','gr_sanitize_danish',0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment