I tried to find an example usage of charset control in visual basic but i couldn’t succeed. I’m trying to show unicode characters (Turkish, Russian, Arabic, etc) on command button, treeview control and listview control.
I’m using the following code to test:
Dim cs As New ChilkatCharset2Lib.ChilkatCharset2
cs.FromCharset = "windows-1254″
cs.ToCharset = "windows-1250″
actually I tested with changing ToCharset and FromCharset also but I couldn’t get the result correctly. The characers there are two Turkish characters.
Is there any way to do this? Can you send me any sample?
Strings in Visual Basic are Unicode. The only way to work with byte data representing characters in a particular charset encoding is with a byte array.
When you pass "đţ" to ConvertData, you are passing a Unicode string (i.e. each character is represented by 2-bytes of data.) However, your code is telling the conversion component that you are passing "windows-1254″ (1 byte/char) data, but you are NOT. Also, ConvertData returns a byte array (in a Variant), but MsgBox is expecting a string (Unicode of course).
If you are trying to display Unicode characters in VB6, your best course of action is to use the Microsoft Forms 2.0 controls (fm20.dll) instead of the default controls. These are Unicode-capable controls (text box, label, list box, etc.) that can display strings (Unicode) in any language. The default VB6 controls do not support Unicode, even though VB6 strings *are* Unicode, go figure! For me, internationalization is one of the biggest reasons for switching to .NET.