Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

80
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda