Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

81
Vistas
Get Char's directionality in JavaScript

I have a method in Java, that takes a Hebrew string, and adjusts its end to a form appropriate to Hebrew. In one of the lines I used in a property Character.getDirectionality(char).

Now, I want to "translate" it to JavaScript. The problem is that I can't find appropriate way to get this property. Yes, there is an option to search in the UnicodeData.txt, but this is 1) can have some problems with the copyright; and 2) it is seems hard. Maybe, there is an Unicode library for JS, or a built-in solution.

Here is my code in Java (I did some corrections in it, but it donesn't matter so much):

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
            //i.e. 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();
}

Thank you very much for help!

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda