Android Question Hebrew Transliteration ...

StephenRM

Member
Why does this code fail?:
        If resTxt.EndsWith("כ") Then
            resTxt = resTxt.Length - 1
            resTxt =  resTxt +"ך"
        End If
        If resTxt.EndsWith("מ") Then
            resTxt = resTxt.Length - 1
            resTxt = resTxt +"ם"
        End If
        If resTxt.EndsWith("נ") Then
            resTxt = resTxt.Length - 1
            resTxt = resTxt + "ן"
        End If
        If resTxt.EndsWith("פ") Then
            resTxt = resTxt.Length - 1
            resTxt =  resTxt + "ף"
        End If
        If resTxt.EndsWith("צ") Then
            resTxt = resTxt.Length - 1
            resTxt =  resTxt  + "ץ"
        End If


The program breaks, and restarts the app. Can't we add Hebrew letters this way?
 

StephenRM

Member
My dear Friends
The problem is solved, I did this in Javascript and copied the same in B4A, the problem was with '+' sign, changed it to '&'.

Problem solved:
        Dim HebTxt As String=  "א,ב,ג,ד,ה,ו,ז,ח,ט,י,כ,ך,ל,מ,ם,נ,ן,ס,ע,פ,ף,צ,ץ,ק,ר,ש,ת,בּ,גּ,דּ,כּ,שׁ,שׂ,תּ,ףּ,פּ,ךּ,א,י,א,ו,ז"
        Dim EngTxt As String="a,b,gh,dh,h,v,z,ch,t,y,c,c,l,m,m,n,n,s,a,f,f,ts,ts,q,r,sh,th,b,g,d,k,sh,si,t,p,p,k,e,i,o,u,j"
        
        Heb_Alpha.Initialize
        Heb_Alpha.Put("a", "א" )
        Heb_Alpha.Put("b", "בּ" )
        Heb_Alpha.Put("c", "כ" )
        Heb_Alpha.Put("d", "ד" )
        Heb_Alpha.Put("e", "א" )
        Heb_Alpha.Put("f", "פֿ" )
        Heb_Alpha.Put("g", "ג" )
        Heb_Alpha.Put("h", "ה" )
        Heb_Alpha.Put("ch","ח")
        Heb_Alpha.Put("i", "י" )
        Heb_Alpha.Put("j", "זשׂ" )
        Heb_Alpha.Put("k", "ק" )
        Heb_Alpha.Put("l", "ל" )
        Heb_Alpha.Put("m", "מ" )
        'Heb_Alpha.Put("m","ם")
        Heb_Alpha.Put("n", "נ" )
        'Heb_Alpha.Put("n","ן")
        Heb_Alpha.Put("o", "א" )
        Heb_Alpha.Put("p", "פּ" )
        Heb_Alpha.Put("q", "ק" )
        Heb_Alpha.Put("r", "ר" )
        Heb_Alpha.Put("s", "ס" )
        Heb_Alpha.Put("t", "ת" )
        'Heb_Alpha.Put("u", "אָ" )
        Heb_Alpha.Put("u", "ו" )
        Heb_Alpha.Put("v", "ו" )
        Heb_Alpha.Put("w", "ו" )
        Heb_Alpha.Put("x", "כּס" )
        'Heb_Alpha.Put("y", "יִי" )
        Heb_Alpha.Put("y","י")
        Heb_Alpha.Put("z", "ז" )
        Heb_Alpha.Put("kh","ח")
        'Heb_Alpha.Put("T","ת")
        'Heb_Alpha.Put("Th","תּ")
        'Heb_Alpha.Put("y","י")
        'Heb_Alpha.Put("k","כ")
        'Heb_Alpha.Put("N","נ")
        'Heb_Alpha.Put("s","ס")
        Heb_Alpha.Put("e","ע")
        Heb_Alpha.Put("f","פ")
        'Heb_Alpha.Put("p","ף")
        Heb_Alpha.Put("si","שׂ")
        Heb_Alpha.Put("sh","שׁ‎")
        'Heb_Alpha.Put("k","ך")
        'Heb_Alpha.Put("ts","ץ")
        Heb_Alpha.Put("ts","צ")
        'Heb_Alpha.Put("u","י")
        'Heb_Alpha.Put("v","ב")
        Heb_Alpha.Put("q","ק")
        'Heb_Alpha.Put("o","ב")
        Heb_Alpha.Put("r","ר")
        'Heb_Alpha.Put("t","ט")
        'Heb_Alpha.Put("ah","הָ")
        'Heb_Alpha.Put("dh","דּ")
        'Heb_Alpha.Put("e"," ")
        'Heb_Alpha.Put("x","")
        
        edtType.Text = edtType.Text.ToLowerCase
        edtType.Text = edtType.Text.Replace("si","שׂ")
        edtType.Text = edtType.Text.Replace("sh","שׁ‎")
        'edtType.Text = edtType.Text.Replace("ts","ץ")
        edtType.Text = edtType.Text.Replace("ts","צ")
        edtType.Text = edtType.Text.Replace("ch","ח")
        edtType.Text = edtType.Text.Replace("kh","ח")
    
        Dim txt As Matcher = Regex.Matcher("\w", edtType.Text)
        Dim resTxt As String, hebVal As String
    
        Do While txt.Find
            If Heb_Alpha.Get(txt.Match )  <> Null Then
                resTxt = resTxt & Heb_Alpha.Get(txt.Match)
            Else
                resTxt = resTxt & txt.Match
            End If
        Loop
        
        If resTxt.EndsWith("כ") Then
            'resTxt = resTxt.SubString2(0, resTxt.LastIndexOf("k"))
            'resTxt = resTxt.Replace("k","ך")
            resTxt =  resTxt.SubString2(0, resTxt.Length - 1)
            hebVal = "ך"
            resTxt =  resTxt & hebVal
        End If
        If resTxt.EndsWith("מ") Then
            'resTxt = resTxt.Replace("m","ם")
            'resTxt = resTxt.SubString2(0, resTxt.LastIndexOf("m"))
            resTxt =  resTxt.SubString2(0, resTxt.Length - 1)
            'resTxt = "ם" + resTxt
            hebVal = "ם"
            resTxt = resTxt & hebVal
        End If
        If resTxt.EndsWith("נ") Then
            'resTxt = resTxt.Replace("n","ן")
            'resTxt = resTxt.SubString2(0, resTxt.LastIndexOf("n"))
            resTxt =  resTxt.SubString2(0, resTxt.Length - 1)
            hebVal = "ן"
            resTxt = resTxt & hebVal
        End If
        If resTxt.EndsWith("פ") Then
            'resTxt = resTxt.Replace("p","ף")
            'resTxt = resTxt.SubString2(0, resTxt.LastIndexOf("p"))
            resTxt =  resTxt.SubString2(0, resTxt.Length - 1)
            hebVal = "ף"
            resTxt =  resTxt & hebVal
        End If
        If resTxt.EndsWith("צ") Then
            'resTxt = resTxt.Replace("ts","ץ")
            'resTxt = resTxt.SubString2(0, resTxt.LastIndexOf("ts"))
            resTxt =  resTxt.SubString2(0, resTxt.Length - 1)
            hebVal = "ץ"
            resTxt =  resTxt  & hebVal
        End If
        edtRes.Text = resTxt
 
Upvote 0

Similar Threads

Top