Surrogate pairs cannot display on form

65 views Asked by At

I'm trying to design a virtual keyboard with character of any language. Everything goes fine, except one point: codes beyond 0xFFFF. I'm using surrogate pairs for codes beyond 0xFFFF, like this:

Dim codeH As Integer
Dim codeL As Integer

If thisCode > 65535 Then
    thisCode = (thisCode - &H10000)
    codeH = &HD800 + (thisCode >> 10)
    codeL = &HDC00 + (thisCode And &H3FF)
    Return (ChrW(codeH) + ChrW(codeL))
Else
    Return ChrW(thisCode)
End If

But as soon I'm using the result as a string to display on a control (richTextBox, label, button, whatever...), all I get is a square or a blank character.

Of course I tried several fonts, even Arial Unicode MS, but I'm still stuck with my squares...

What am I missing ? Any solution ?

0

There are 0 answers