B4J Question Chr() for more than 2 bytes unicode support

kimstudio

Active Member
Licensed User
Longtime User
Does chr() function only support 2 bytes unicode? also Asc().
I am trying to use the updated Material design icon font, which includes more than 6000 icons now, and its code is more than 2 bytes. If use chr(0xF1A29) it doens't work, however if directly copy the character to label.text it works.

屏幕截图 2022-05-22 213900.png


B4X:
Label1.Text = Chr(0xF1A29) 'NO
Label1.Text = "?" 'YES
 
Solution
B4X:
    Dim fx As JFX
    Dim IconsFont As B4XFont = xui.CreateFont(fx.LoadFont(File.DirAssets,"materialdesignicons-webfont.ttf",64),64)
    Label1.Font = IconsFont
    Label1.Text = UnicodeToString(0xF1A28) & UnicodeToString(0xF1A29) & UnicodeToString(0xF1A2A)
1653283390522.png

TILogistic

Expert
Licensed User
Longtime User
see

use:
UnicodeToString(0xF1028)
B4X:
Sub UnicodeToString (code As Int) As String
    Dim bc As ByteConverter
    Dim b() As Byte = bc.IntsToBytes(Array As Int(code))
    Return BytesToString(b, 0, 4, "UTF32")
End Sub
 
Upvote 0
Top