You are not recognized as the original poster of this topic.
UnicodeRange=(a,b)=>Array.from({length:b-a+1},(_,i)=>String.fromCharCode(a+i)).join("");
katakanaToHalfWidth=str=>{
let s=0xFF65,t="・ヲァィゥェォャュョッーアイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン",
o="";
loop:for(let i=0,c;i<str.length;i++){
c=str[i],cc=c.charCodeAt(0);
if(t.indexOf(c)>=0){
o+=String.fromCharCode(s+t.indexOf(c));
}else if(cc>=0x30AB&&cc<=0x30DD){ //dakuten゙ and handakuten゚
for(let j=1;j<3;j++){
let f=t.indexOf(String.fromCharCode(cc-j));
if(f>=0){
o+=String.fromCharCode(s+f)+"゙゚"[j-1];
continue loop;
}
}
o+=c;
}else if(cc>=0x21&&cc<=0x7E){ //basic Latin (full-width, feel free to comment out this)
o+=String.fromCharCode(cc+(0xFF01-0x21));
}else{
o+=({"。":"。","「":"「","」":"」","、":"、"})[c]??c;
}
}
return o;
};
console.log((UnicodeRange(0x21,0x7E)+UnicodeRange(0x30A1,0x30FF)+"。「」、").split("").map(x=>x+" - "+katakanaToHalfWidth(x)).join("\n"));
console.log(katakanaToHalfWidth("チャスモハァーワ」。")); //チャスモハァーワ」。