Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicPythonRubySQL ServerSwiftTclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.js

Visual Basic 6.0 Examples

Email Object
MHT / HTML Email
Java KeyStore (JKS)
RSA Encryption
Tar Archive

More Examples...
Google APIs
Google Cloud Storage
Azure Cloud Storage
Amazon S3 (new)
Google Drive
Amazon S3
Bounced Email
DKIM / DomainKey








(Deprecated and No Longer Available)
Display Japanese in VB6 on Any Computer Regardless of Locale

Notice: The "ToVB6" method described in this document is deprecated, no longer available, and no longer supported. It never worked 100%, and it cannot ever work 100%.

This information remains available for legacy Chilkat customers that might still be using the functionality, which is not perfect, and can never actually be perfect. Updating to VB.NET is the only real solution.

Do not send email requesting this functionality. It will NOT BE ANSWERED.

This example applies to any language: Japanese, Chinese, Korean, Hebrew, Arabic, Czech, Vietnamese, Thai, Russian, etc.

Our previous example discussed what you absolutely need to know if you are intending to display foreign characters using the standard VB6 textbox and label controls.

In summary: VB6 stores strings as Unicode. When a textbox or label control displays a string, it first does an internal conversion from Unicode to the ANSI charset of the computer on which its running. It then interprets the resulting bytes according to the Font.Charset property of the control.

You would think that nothing more is required than to set the Font.Charset equal to the correct integer value for the language to be displayed and then set the control's Text property equal to the Unicode string. This works if you're computer's locale is the same as the language of the text being displayed (i.e. your displaying Chinese text on a Chinese computer, or Greek text on a Greek locale computer). However, it does not work when the locale of the computer is something different.

PS> Here are the values for Font.Charset required for different languages:

	128   	Japanese, Shift_JIS (Japanese Industry Standard)
	129   	Korean, ks_c_5601-1987
	130    	Korean, johab
	134   	Simplified Chinese, gb2312 - Mainland China(PRC) and Singapore
	136   	Traditional Chinese, big5 - Taiwan and Hong Kong
	161 	Greek, windows-1253
	162 	Turkish, windows-1254
	163 	Vietnamese, windows-1258
	177 	Hebrew, windows-1255
	178 	Arabic, windows-1256
	186 	Baltic, windows-1257
	204 	Cyrillic, windows-1251 - Russia, Belarus, Ukraine...
	222 	Thai, windows-874
	238 	Central/Eastern European, windows-1250 


Introducing the ToVB6 Method

Notice: The "ToVB6" method described in this document is deprecated and no longer supported.

The Chilkat Charset ActiveX can be downloaded HERE

The Chilkat Charset component includes a "ToVB6" method that makes it possible to display a Unicode string for a particular language in a standard textbox or label control. It will work correctly regardless of the locale of the computer on which it is running. Rather than setting the control's Text property equal to the Unicode string directly, you should set it to the string returned by ToVB6.

    Dim cc As New ChilkatCharset2
    cc.UnlockComponent "anything for 30-day trial"
    ' Load a Japanese string encoded in utf-8 into memory:
    Dim utf8Bytes As Variant
    utf8Bytes = cc.ReadFile("utf8_japanese.txt")
    ' Convert it to a Unicode string:
    Dim japaneseUni As String
    cc.FromCharset = "utf-8"
    japaneseUni = cc.ConvertToUnicode(utf8Bytes)
    ' We now have a Unicode string with Japanese characters.
    ' Set the Font.Charset on our textboxes for Japanese:
    Text1.Font.Charset = 128
    Text2.Font.Charset = 128
    ' You would expect that setting Text1.Text = japaneseUni
    ' would display the Japanese characters correctly.
    ' It does on a computer in Japan, but not on
    ' non-Japanese computers:
    Text1.Text = japaneseUni
    ' Why???  Because VB6 is (internally) converting
    ' Unicode to ANSI first and then interpreting the ANSI
    ' bytes according to the Font.Charset setting.
    ' Text1.Text will display question marks on non-Japanese
    ' computers because the implicit (and internal)
    ' Unicode-to-ANSI conversion fails.  (Japanese characters
    ' are not representable in Windows-1252.)
    ' What you need instead is to convert the Unicode string
    ' to another Unicode string such that when VB6 does
    ' the Unicode-to-ANSI conversion, you end up with Shift_JIS
    ' regardless of the locale of the computer.
    ' This is exactly what the ToVB6 method does:
    Dim correctForDisplay As String
    correctForDisplay = cc.ToVB6(japaneseUni, "Shift_JIS")
    Text2.Text = correctForDisplay
    ' Note: The correctForDisplay string should only be used for displaying
    ' the Japanese string.



© 2000-2016 Chilkat Software, Inc. All Rights Reserved.