Skip to content

Instantly share code, notes, and snippets.

@dcabines
Last active June 17, 2016 01:30
Show Gist options
  • Select an option

  • Save dcabines/7995bdcd1187910a3441 to your computer and use it in GitHub Desktop.

Select an option

Save dcabines/7995bdcd1187910a3441 to your computer and use it in GitHub Desktop.
Cᴏɴᴠᴇʀᴛ ʟᴏᴡᴇʀ ᴄᴀsᴇ ʟᴇᴛᴛᴇʀs ɪɴ ᴀ sᴛʀɪɴɢ ᴛᴏ sᴍᴀʟʟ ᴄᴀᴘs. Fᴀᴄᴇʙᴏᴏᴋ sᴜᴘᴘᴏʀᴛs sᴍᴀʟʟ ᴄᴀᴘs.
window.toSmallCaps = (function () {
var letters = "abcdefghijklmnopqrstuvwxyz";
var caps = "ᴀʙᴄᴅᴇғɢʜɪᴊᴋʟᴍɴᴏᴘǫʀsᴛᴜᴠᴡxʏᴢ";
return function replace(value) {
var newValue = '';
for (i = 0; i < value.length; i++) {
var letter = value[i];
var index = letters.indexOf(letter);
newValue += index !== -1 ? caps.charAt(index) : letter;
}
return newValue;
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment