Last active
May 31, 2022 08:52
-
-
Save yudukikun5120/7cba194673ef9fc803b4d3216778c20a to your computer and use it in GitHub Desktop.
The Javascript for Automation script for converting text to monospace symbols.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function run (input, parameters) { | |
const plainText = input[0].toString() | |
const charCodes = [] | |
for (const char of plainText) { | |
const charCode = char.charCodeAt() | |
let convertedCharCode = 0 | |
if (char >= 'A' && char <= 'Z') { | |
convertedCharCode = charCode + code_bwn_types('capital') | |
} else if (char >= 'a' && char <= 'z') { | |
convertedCharCode = charCode + code_bwn_types('lower') | |
} else { | |
convertedCharCode = charCode | |
}; | |
charCodes.push(convertedCharCode) | |
}; | |
const convertedText = String.fromCodePoint(...charCodes) | |
return convertedText | |
}; | |
code_bwn_types = (type) => { | |
if (type === 'capital') { | |
return code_bwn_symbols('𝙰', 'A') | |
} else if (type === 'lower') { | |
return code_bwn_symbols('𝚊', 'a') | |
}; | |
}; | |
code_bwn_symbols = (styled_ltr, ltr) => { | |
return styled_ltr.codePointAt() - ltr.codePointAt() | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
About
JXA (JavaScript for Automation) script to convert text to monospace symbols (1D670 - 1D6A3).
Reference