ブックマークレット、つい最近また業務用に(勝手に)作成しました。
いつになったら私の仕事はAIが奪ってくれるんです!?!?
おかげでVBAで(勝手に)業務改善してますよ!?!?
本題なんですけど、iPhoneのメモ帳の片隅に、用途不明のブックマークレットを見つけました。
「半角カナにするブックマークレット的な」と書いてあったので、おそらくiPhoneが半角カナに対応していなかった(?)頃に作ったんだと思うんですけど、今普通に標準キーボードで入力できてますからね。
いやでも関数がiPhone用なのかな・・・分からないんですけど。
なんか消すのは勿体ないけど調べるのも面倒だし、記事内にベタ打ちでブログにアップしちゃいますね。
javascript:var%20str=String(window.getSelection()),text=new%20String(),n;for(i=0;i<str.length;i++){n=str.charCodeAt(i);if(n==32){text+=String.fromCharCode(12288);}else%20if(n==12288){text+=String.fromCharCode(32);}else%20if(n>=33&&n<=126){text+=String.fromCharCode(65248+n);}else%20if(n>=65281&&n<=65374){text+=String.fromCharCode(n-65248);}else{text+=String.fromCharCode(n);}}alert(text);
[a-z][A-Z][0-9][a-z][A-Z][0-9][!-~][!-~][ヲ-ン][ァ-ヴ]
33~126
65281~65374
半角⇒全角
javascript:var str=String(window.getSelection()),text=new String(),n;for(i=0;i<str.length;i++){n=str.charCodeAt(i);if
(n==32){text+=String.fromCharCode(12288);}else if(n>=33&&n<=126){text+=String.fromCharCode(65248+n);}else{text
+=String.fromCharCode(n);}}alert(text);
全角⇒半角
javascript:var str=String(window.getSelection()),text=new String(),n;for(i=0;i<str.length;i++){n=str.charCodeAt(i);if
(n==12288){text+=String.fromCharCode(32);}else if(n>=65281&&n<=65374){text+=String.fromCharCode(n-65248);}else{text
+=String.fromCharCode(n);}}alert(text);
半角⇔全角
javascript:var str=String(window.getSelection()),text=new String(),n;for(i=0;i<str.length;i++){n=str.charCodeAt(i);if
(n==32){text+=String.fromCharCode(12288);}else if(n==12288){text+=String.fromCharCode(32);}else if(n>=33&&n<=126){text
+=String.fromCharCode(65248+n);}else if(n>=65281&&n<=65374){text+=String.fromCharCode(n-65248);}else{text
+=String.fromCharCode(n);}}alert(text);
特に害は無いと思いますけど使用は自己責任でお願いします。