Android Code Snippet UnicodeToString

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
Longtime User
Erel posted a sample too. :)

upload_2015-1-18_9-23-24-png.31297


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