Tengo un método en Java, que toma una cadena hebrea y ajusta su final a una forma apropiada para el hebreo. En una de las líneas que usé en una propiedad Character.getDirectionality(char) .
Ahora, quiero "traducirlo" a JavaScript. El problema es que no puedo encontrar la forma adecuada de obtener esta propiedad. Sí, hay una opción para buscar en UnicodeData.txt , pero esto es 1) puede tener algunos problemas con los derechos de autor; y 2) parece difícil. Tal vez, hay una biblioteca Unicode para JS o una solución integrada.
Aquí está mi código en Java (le hice algunas correcciones, pero no importa tanto):
public static String endingPointed(String s) { int i=s.length()-1; //max. length of the while loop StringBuffer sb=new StringBuffer(s); //mutable String I will change during the method while(i>=0) { //the loop //ie vocalization checking if(Character.getDirectionality(s.charAt(i))==Character.DIRECTIONALITY_NONSPACING_MARK){ i--; if(sofiyot.contains(s.charAt(i)+"")) { //next letters: כמנפצ; they have ending form sb.replace(i, i+1, (char) (s.charAt(i)-1)+""); //replacement to the ending form if(s.endsWith("כ")||s.endsWith("כּ")) sb.append("ְ"); //if a pointed word ends with 'ך', the letter accepts schva ('ְ'). Ex. "אֵיךְ" (ekh), means 'how' return sb.toString(); } if(patach.contains(s.charAt(i)+"")) { //in the pointed writing, the letters החע accept patach ('ַ'). Ex. "תַּפּוּחַ" (tapuakh), means 'apple' if(!s.endsWith("ָ"+s.charAt(i))&!s.endsWith("ַ"+s.charAt(i))) //except when the letters are dotted with patach ('ַ') or kamatz ('ָ') sb.append("ַ"); return sb.toString(); } else return sb.toString(); } return sb.toString(); }¡Muchas gracias por la ayuda!