Created
June 6, 2016 17:11
-
-
Save jkap/c3eea696e0a68b03bd9c7e8ec93c223f to your computer and use it in GitHub Desktop.
put this in a drafts action to replace yr draft with its full-width equivalent
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 fullWidth(input) { | |
var | |
dict = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}", | |
offset = 65281, | |
out = "", | |
n, | |
letter, | |
codePoints = [], | |
index; | |
for (n = 0; n < input.length; n++) { | |
letter = input.charAt(n) | |
if (letter === " ") { | |
letter = 0x3000; | |
} else { | |
index = dict.indexOf(letter) | |
if (index !== -1) { | |
letter = offset + index; | |
} else { | |
letter = input.charCodeAt(n); | |
} | |
} | |
codePoints.push(letter) | |
} | |
out = String.fromCharCode.apply(String, codePoints); | |
return out | |
} | |
draft.content = fullWidth(draft.content); | |
commit(draft); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment