Possible Duplicate:
What’s the best option to display Unicode text (hebrew, etc.) in VB6
What is the correct way to display the unicode character 9646
(BLACK VERTICAL RECTANGLE) in VB6?
When I try ChrW(9646)
it displays ?
.
Possible Duplicate:
What’s the best option to display Unicode text (hebrew, etc.) in VB6
What is the correct way to display the unicode character 9646
(BLACK VERTICAL RECTANGLE) in VB6?
When I try ChrW(9646)
it displays ?
.
Here is a tutorial to explore. Take a look at this article for the black vertical rectangle.
Assuming Unicode is turned on, send the following string to a window to display:
Wchar_t mStr[] = {9646,0,0};
Reference. This code snippet and reference is more inlined with C++. Where you would turn off/on UNICODE in Visual C++ using following steps:
Open your project in VS2008/2010;
Right click the project in Solution Explorer and click Properties;
Select
Configuration Properties-> General
, selectCharacter Set
and change thecurrent value
toUse Multi-Byte Character Set
. (turning off)Good article aboubt displaying UNICODE in VB.
When you are working with a
textbox
control in aForm
, add theMicrosoft Forms 2.0 Object Library
as a reference library. This component provides Unicode supportted controls, such as: textbox, label, command button,list box, combo box, checkbox, radio button, toggle button, image, tabstrip, and multiple page control.Working with VB6 and displaying non-us-ANSI characters you need 3 main things to understand:
After the
Unicode-to-ANSI
conversion, VB6 then attempts to display the character data according to the control'sFont.Charset
property, which if left unchanged is equal to the ANSI charset. Changing the control'sFont.Charset
changes the way VB6 interprets the "ANSI" bytes. In other words, you're telling VB6 to treat the bytes as some other character encoding instead of "ANSI".For e.g. consider trying to display a
Unicode Japanese
string on anEnglish
computer: You set theFont.Charset = 128
(for Japanese), but your Unicode string displays as all question mark characters. It's because VB6 is first trying to convert your Japanese Unicode string to ANSI, which is Windows-1252 for English computers. Japanese characters are not representable in Windows-1252. Each character fails to convert and is replaced with a question mark. for e.g. Selecting the Japanese script in the TextBox control's property settings is the same as setting the Font.Charset at runtime.As Jukka said
Font
plays a vital role showing UNICODEs given the availability of the characters within a Font. As Hans said,glyph
unsupported Font produces a rectangle. So you need to make sure theFont
you select is capable of rendering glyphs. For e.g.MS Sans Serif
font does not renderƒ
(LATIN SMALL LETTER F WITH HOOK, 2-byte Unicode value is 0x0192), so you'll see a thin solid rectangular box in its place. However on Windows, there are very few fonts with a wide enough character repertoire to represent Chinese..In the following code the Font Name () is set during Run Time along the Font CharSet
Charset properties:
Code:
Output in VBE IDE: You may give it a try in VB6 form as well.
After all the above writing, I noticed this MSDN article. Well at least it's VB confirmation :D
What you need is to use "Unicode aware" controls. VB6 only came with a few of these, though in Vista and later or XP (Tablet Edition only unless you use the non-Ink redist version of this library) the InkEdit control can do this.
Note the
$
which indicates a function returning a String instead of a Variant with one embedded in it.An InkEdit control is really an enhanced RichTextBox that supports ink entry as well as typing on ink-enabled systems. It is also a Unicode control, and one that supports Unicode properties such as
.Text
.The standard MSHFlexGrid, DataGrid, and a few other controls are also Unicode-aware.
See http://www.alanwood.net/unicode/geometric_shapes.html for characters like the one in question. You can basically ignore the jibber-jabber about ANSI, Charset, etc. It is relevant but not applicable here.
▮ 9646 ▮ 25AE BLACK VERTICAL RECTANGLE
The reason why it displays a question mark is that the character is not present in the font being used. You need to set the font to one that supports BLACK VERTICAL RECTANGLE, such as Arial Unicode MS or Lucida Sans Unicode.