|
"Strange characters" - Unicode replacement (VB6)The problem was easy: a langauge learning program had to show german and polish characters. Maybe american people wonder about the funny characters in all the european languages? So our developer's machines did, too. The languages sentences are strored in a database system. To produce this database it was helpful to use Access 2000 and unicode character sets. But today in times of VB6 it isnt able to handle this correctly in labels and textboxes. The polish parts have to be shown using the central european codepage, for the german we need the western european. Now there was the following problem: VB did its job in a way, that very strange characters were shown. Correctly shown polish characters did only appear, whenn we put "wrong" characters to the database. These wrong characters were these we got when showing polish text using western european codepage. :-?
The function StrConv(string, vbUnicode) gives us back a string that looks something strange: any s e c o n d character seems to be a blank. But looking closer to this, we recognized, this was our point of interest. :-!) The code of such a character may be =0, then it is a normal character. Codes <>0 show us, this is a special unicode character.
So, let us try a funny thing: Private Function DoStringChangeCodes_d_pl(sSrc As String) As String
Dim i As Integer
Dim b1 As Variant, b2 As Variant
Dim n1, n2
Dim sX As String
Dim sNeu As String
sNeu = ""
sX = StrConv(sSrc, vbUnicode)
Else ' What is that???
MsgBox "Unexpected char!" & Chr(13) & _
"Code: " & n1 & "." & n2, vbCritical, "Ooops - ???"
End If
Next i
DoStringChangeCodes_d_pl = sNeu
End Function
This function after finishing the DB production replaces any polish unicode characters.
|