Android Code Snippet UnicodeToString

LucaMs

Expert
Licensed User
SubName: UnicodeToString

Author: Erel

Description: allows you to insert Unicode "special" characters in text strings.

Code:
B4X:
Sub UnicodeToString (codepoint As Int) As String
   Dim bc As ByteConverter
   Dim b() As Byte = bc.IntsToBytes(Array As Int(codepoint))
   Return BytesToString(b, 0, 4, "UTF32")
End Sub
Dependencies: ByteConverter library

Tags: Unicode, Characters, Text
 

DonManfred

Expert
Licensed User
Erel posted a sample too. :)



B4X:
Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")
   WebView1.LoadHtml("<p>&#xFE4E6;</p>")
   EditText1.Text = UnicodeToString(0xFE4E6)
End Sub

Sub UnicodeToString (codepoint As Int) As String
   Dim bc As ByteConverter
   Dim b() As Byte = bc.IntsToBytes(Array As Int(codepoint))
   Return BytesToString(b, 0, 4, "UTF32")
End Sub
 
Top