B4J Question [B4X] [BCTextEngine] Japanese remains single-line

Alexander Stolte

Expert
Licensed User
Longtime User
I got a 3 star rating because since the last update it displays one line in Japanese.
I had switched to BCTextEngine to implement new text features.

I have an example project in the attachment, what do i have to do so that japanese multi line is displayed?

B4X:
    BBLabel1.TextEngine = TextEngine
    BBLabel1.Text = "ログノートとしては、シンプルで使い勝手がよく気に入っていました。ただ残念ながら先日のアップデートで日本語で入力すると、折り返し表示がされずに一目で全文を見返すことができなくなりました。自分で書いたログを読むためにはいちいち編集画面に行く必要があります。早急に改善してほしいです。ちなみに半角英数字だと折り返し表示されます。"
 

Attachments

  • BBLabel Japanese.zip
    177.6 KB · Views: 96

Alexander Stolte

Expert
Licensed User
Longtime User
My workaround is this:
B4X:
BBLabel1.Text = InsertZeroWidthSpaces("ログノートとしては、シンプルで使い勝手がよく気に入っていました。ただ残念ながら先日のアップデートで日本語で入力すると、折り返し表示がされずに一目で全文を見返すことができなくなりました。自分で書いたログを読むためにはいちいち編集画面に行く必要があります。早急に改善してほしいです。ちなみに半角英数字だと折り返し表示されます。")
B4X:
Sub InsertZeroWidthSpaces(Text As String) As String
    Dim sb As StringBuilder
    sb.Initialize
    For i = 0 To Text.Length - 1
        Dim ch As String = Text.CharAt(i)
        sb.Append(ch)
        ' Nur bei japanischen Zeichen einen Zero-Width Space einfügen
        If IsCJKCharacter(ch) Then sb.Append(" ")
    Next
    Return sb.ToString
End Sub



Sub IsCJKCharacter(ch As String) As Boolean
    Dim code As Int = Asc(ch)
    Return (code >= 0x4E00 And code <= 0x9FFF) Or _ ' Chinesisch & Kanji
           (code >= 0x3040 And code <= 0x30FF) Or _ ' Hiragana
           (code >= 0x31F0 And code <= 0x31FF) Or _ ' Katakana-Erweiterung
           (code >= 0x3400 And code <= 0x4DBF) Or _ ' Seltene Kanji
           (code >= 0x20000 And code <= 0x2A6DF) ' Erweiterte Kanji
End Sub

i insert a space after each japanese character
 
Upvote 0

PaulMeuris

Well-Known Member
Licensed User
The java BreakIterator can be used to break up a line of a foreign language text into words.

1738638807571.png
1738639211135.png

Remove the comment on the output line to show each word on the next line.
You can find the source code for this testproject in the attachment.
Maybe this helps...
 

Attachments

  • 1738638637398.png
    1738638637398.png
    56.8 KB · Views: 87
  • breakiterator.zip
    3.2 KB · Views: 80
Last edited:
Upvote 0
Top