vangog
05-13-2022, 10:54 AM
I have this code
' See Unicode table for hebrew: https://zims-en.kiwix.campusafrica.gos.orange.com/wikipedia_en_all_nopic/A/Unicode_and_HTML_for_the_Hebrew_alphabet
Sub checkHebrewCharRange(r As Range)
Dim b() As Byte, i As Long, a As Long
b = r.Text ' converts the string to byte array (2 or 4 bytes per character)
'Debug.Print "'" & r & "'"; r.LanguageID; r.LanguageIDFarEast; r.LanguageIDOther
For i = 1 To UBound(b) Step 2 ' 2 bytes per Unicode codepoint
If b(i) > 0 Then ' if AscW > 255
a = b(i): a = a * 256 + b(i - 1) ' AscW
Select Case a
'64298 FB2A sin to 64331 FB4A
Case &HFB2A To &HFB4A
r.HighlightColorIndex = wdBrightGreen:
r.Font.Size = 24
Exit Sub
Case &H5BE To &H5F4:
r.HighlightColorIndex = wdBrightGreen:
r.Font.Size = 24
Exit Sub
Case &HFB2A To &HFB4A:
r.HighlightColorIndex = wdBrightGreen:
r.Font.Size = 24
Exit Sub
' Case &H1F00 To &H1FFF: r.HighlightColorIndex = wdBlue: Exit Sub ' Greek Extended
' Case Else: r.HighlightColorIndex = wdRed: Debug.Print Hex(a), r.End - r.Start ' other
End Select
End If
Next
End Sub
I want to detect shin character in hebrew text in Word. This is this part:
Case &HFB2A
This is implementation of the above code:
Dim r As Range, t As Double: t = Timer
Application.ScreenUpdating = False
If Len(Selection.Range.Text) = 0 Then
MsgBox "Nejprve vyberte text kde jsou hebr. znaky. Please select the text including hebrew characters."
End If
For Each r In Selection.Range.Characters
checkHebrewCharRange r
Next
Application.ScreenUpdating = True
Where I use it like the following. I select the text שׁוב and then I run the macro. The שׁ needs to be detected. I suppose that shin is out of two byte range...
' See Unicode table for hebrew: https://zims-en.kiwix.campusafrica.gos.orange.com/wikipedia_en_all_nopic/A/Unicode_and_HTML_for_the_Hebrew_alphabet
Sub checkHebrewCharRange(r As Range)
Dim b() As Byte, i As Long, a As Long
b = r.Text ' converts the string to byte array (2 or 4 bytes per character)
'Debug.Print "'" & r & "'"; r.LanguageID; r.LanguageIDFarEast; r.LanguageIDOther
For i = 1 To UBound(b) Step 2 ' 2 bytes per Unicode codepoint
If b(i) > 0 Then ' if AscW > 255
a = b(i): a = a * 256 + b(i - 1) ' AscW
Select Case a
'64298 FB2A sin to 64331 FB4A
Case &HFB2A To &HFB4A
r.HighlightColorIndex = wdBrightGreen:
r.Font.Size = 24
Exit Sub
Case &H5BE To &H5F4:
r.HighlightColorIndex = wdBrightGreen:
r.Font.Size = 24
Exit Sub
Case &HFB2A To &HFB4A:
r.HighlightColorIndex = wdBrightGreen:
r.Font.Size = 24
Exit Sub
' Case &H1F00 To &H1FFF: r.HighlightColorIndex = wdBlue: Exit Sub ' Greek Extended
' Case Else: r.HighlightColorIndex = wdRed: Debug.Print Hex(a), r.End - r.Start ' other
End Select
End If
Next
End Sub
I want to detect shin character in hebrew text in Word. This is this part:
Case &HFB2A
This is implementation of the above code:
Dim r As Range, t As Double: t = Timer
Application.ScreenUpdating = False
If Len(Selection.Range.Text) = 0 Then
MsgBox "Nejprve vyberte text kde jsou hebr. znaky. Please select the text including hebrew characters."
End If
For Each r In Selection.Range.Characters
checkHebrewCharRange r
Next
Application.ScreenUpdating = True
Where I use it like the following. I select the text שׁוב and then I run the macro. The שׁ needs to be detected. I suppose that shin is out of two byte range...