Skip to content

Instantly share code, notes, and snippets.

@yudukikun5120
Last active May 31, 2022 08:52
Show Gist options
  • Save yudukikun5120/7cba194673ef9fc803b4d3216778c20a to your computer and use it in GitHub Desktop.
Save yudukikun5120/7cba194673ef9fc803b4d3216778c20a to your computer and use it in GitHub Desktop.
The Javascript for Automation script for converting text to monospace symbols.
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()
};
@yudukikun5120
Copy link
Author

About

JXA (JavaScript for Automation) script to convert text to monospace symbols (1D670 - 1D6A3).

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment