Skip to content

Instantly share code, notes, and snippets.

@stream7
Last active December 22, 2015 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stream7/6524603 to your computer and use it in GitHub Desktop.
Save stream7/6524603 to your computer and use it in GitHub Desktop.
toUpperCase for Greek chars
/*global define*/
'use strict';
define(function () {
var map = {
'ά': 'A',
'Ά': 'Α',
'έ': 'Ε',
'Έ': 'Ε',
'ή': 'Η',
'Ή': 'Η',
'ί': 'Ι',
'Ί': 'Ι',
'ό': 'Ο',
'Ό': 'Ο',
'ύ': 'Υ',
'Ύ': 'Υ',
'ώ': 'Ω',
'Ώ': 'Ω'
},
regexp = /(ά|Ά|έ|Έ|ή|Ή|ί|Ί|ό|Ό|ύ|Ύ|ώ|Ώ)/;
function toUpperCase (string) {
if (!regexp.test(string)) {
return string;
}
var upperCase = '',
size = string.length,
i, letter;
for (i = 0; i < size; i++) {
letter = string[i];
if (map[letter]) {
upperCase += map[letter];
} else {
upperCase += letter.toUpperCase();
}
}
return upperCase;
}
return toUpperCase;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment