Well, I think this topic is not quite as trivial.
I'm struggling around with unicode text display as well at the moment.
You must know that usual VB controls except ListView and MSHFlexGrid are actually not unicode-aware. I'm not sure if you can put foreign writing into a usual button's caption, even if the reginal settings are given. (Have not tried that)
The controls of the Forms2.0 library, however, accept unicode characters of any language, as long as the font is installed on the computer. I was able to display Urdu, Farsi, Tamil and also Thai in any Form2.0 control, as well as in the ListView and the MSHFlexGrid, although, ListView gave up when trying to put unicode characters into the column headers. It just converted them to ANSI, as it seems, showing ??????? instead.
VERSION 5.00
Begin VB.Form Form1
Caption = "VB6 Unicode Example 1"
ClientHeight = 2505
ClientLeft = 60
ClientTop = 450
ClientWidth = 7245
LinkTopic = "Form1"
ScaleHeight = 2505
ScaleWidth = 7245
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command1
Caption = "Go"
Height = 375
Left = 240
TabIndex = 2
Top = 1920
Width = 1215
End
Begin VB.TextBox Text2
BeginProperty Font
Name = "Arial"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 1
Text = "Western European"
Top = 1320
Width = 6735
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "MS UI Gothic"
Size = 8.25
Charset = 128
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 0
Text = "Japanese"
Top = 480
Width = 6735
End
Begin VB.Label Label2
Caption = "Font: Arial w/ Western script selected:"
Height = 375
Left = 240
TabIndex = 4
Top = 960
Width = 3615
End
Begin VB.Label Label1
Caption = "Font: MS UI Gothic w/ Japanese script selected:"
Height = 375
Left = 240
TabIndex = 3
Top = 120
Width = 4335
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim s1 As String
s1 = "ƒp"
' The Font for the Text1 textbox is set to
' MS UI Gothic w/ the Japanese script selected.
' It displays a single Japanese character.
Text1.Text = s1
' The Font for Text is set to Arial w/ the
' Western script selected.
' It displays the two characters as you see them
' in the literal string above.
Text2.Text = s1
End Sub
Last edited by dglienna; August 8th, 2011 at 10:34 AM.
Yes, David, I know about this sample and I know about this displaying of Japanese and Chinese characters which make people think "oh look, the VB6 TextBox can display unicode".
That's not the real thing after all. It cannot.
Try to show Tamil, Bengal or even russian cyrillics. It wouldn't work. Not with Thai at all.
The only controls which can really display Unicode strings are the MSHFlexGrid, ListView and the Forms2.0 controls, up to a certain extend.
I made a lot of tries recently and find a couple of strange problems when displaying foreign fonts' character sets.
!!First of all, Windows is aware of UTF16 encoding in the mentioned controls, which allows you to display most of the foreign languages like Punjabi, Tamil, Korean, Thai and even Inuktitut, as long as you have a fitting font installed on your computer.
Forms2.0, MSHFlexGrid and ListView seem to support (to a certain limited extend) the so called Font FallBack. That means, you set the Font of a TextBox or FlexGrid to "Arial" and read (or copy) some Arabic characters to the control. Font FallBack will now find that Arial has not the desired characters defined and will find the next font which supports the desired UTF16 wide characters. (Sometimes it doesn't and I'm still wondering why it does not work all the times).
Also when reading data from files you'd have to watch certain rules of getting unicode characters read in. You'd have to read byte arrays with Get or with InputB to achieve proper unicode input.
It's all really complex and I'm still not down to the bottom of it.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.