How to display Unicode characters in VB6?

Possible duplicate:
What is the best option for displaying Unicode text (Hebrew, etc.) in VB6

What is the correct way to display a Unicode 9646 (BLACK VERTICAL RECTANGLE) character in VB6?

When I try ChrW(9646) , does it display ? .

+2
source share
3 answers

Here is a tutorial to learn. Take a look at this article for a black vertical rectangle .

Assuming Unicode is enabled, send the following line to a window to display:

Wchar_t mStr[] = {9646,0,0};

Link This code snippet and link are described in more detail in C ++. If you disable / enable UNICODE in Visual C ++ using the following steps:

  1. Open your project in VS2008 / 2010;

  2. Right-click the project in Solution Explorer and select Properties;

  3. Select " Configuration Properties-> General , select" Character Set and change the current value to " Use Multi-Byte Character Set . (Shutdown)


A good article does not match the mapping of UNICODE to VB .

When you work with the textbox control textbox in Form , add the Microsoft Forms 2.0 Object Library as a reference library. This component provides Unicode-supported controls , such as: text box, label, command button, list box, combo box, check box, radio button, toggle button, image, tab, and multi-page control.

When working with VB6 and displaying characters other than US-ANSI, you need to know three basic things:

  • Internally, VB6 stores strings as Unicode.
  • When a string is displayed, the standard text and VB6 controls perform an implicit (and internal) conversion from Unicode to ANSI.
  • Standard text and VB6 controls display ANSI bytes according to the character encoding you can specify.

After converting to Unicode-to-ANSI , VB6 then attempts to display character data in accordance with the Font.Charset property of the Font.Charset control, which, if left unchanged, is equal to ANSI encoding. Control change Font.Charset changes the way VB6 interprets ANSI bytes. In other words, you say that VB6 treats bytes as some character encoding instead of "ANSI".

For example, Font.Charset = 128 display the Unicode Japanese string Unicode Japanese on an English computer: you set Font.Charset = 128 (for Japanese), but your Unicode string is displayed as all question mark characters. This is because VB6 first tries to convert your Japanese Unicode string to ANSI, which is Windows-1252 for English computers. Japanese characters are not displayed in Windows-1252. Each character cannot be converted and is replaced by a question mark. for example, to select a Japanese script in the property settings of the TextBox control is the same as setting Font.Charset at run time.

As Yucca said, Font plays a vital role in showing UNICODE, given the presence of characters in the Font. As Hans said, a glyph unsupported font creates a rectangle. Therefore, you need to make sure that your chosen Font is able to display glyphs . For example, the MS Sans Serif does not display ƒ (LATIN SMALL LETTER F WITH HOOK, 2-byte Unicode value is 0x0192), so a thin solid rectangular box will appear in its place. However, there are very few fonts on Windows with a wide enough repertoire to represent the Chinese ..

In the following code, the font name () is set during runtime along the CharSet font

Charset Properties:

 134 Simplified Chinese, gb2312 - Mainland China(PRC) and Singapore 136 Traditional Chinese, big5 - Taiwan and Hong Kong 

The code:

 Sub changeToUniCodes() Dim strTxt2 As String UserForm1.TextBox2.Font.Charset = 134 '--CHINESESIMPLIFIED_CHARSET UserForm1.TextBox2.Font.Name = ChrW(&H5B8B) + ChrW(&H4F53) '-- 宋体 SimSun font UserForm1.TextBox2.Text = ChrW(37446) strTxt2 = UserForm1.TextBox2.Text 'notice that ChrW(9246) produces a different character in Chinese UserForm1.TextBox2.Text = strTxt2 & " " & ChrW(9246) End Sub 

Conclusion in the VBE IDE: you can try also in the form of VB6.

enter image description here

After all the above letter, I noticed this MSDN article. Well, at least this is a confirmation of VB: D

+5
source

What you need to do is use Unicode aware. VB6 appeared only with some of them, although in Vista and later versions or XP (Tablet Edition), only if you are using an unrealized version of this library not for Ink), the InkEdit control can do this.

 InkEdit1.Text = ChrW$(9646) 

Pay attention to $ , which points to a function that returns a string instead of a variant with one built in to it.

The InkEdit control is a truly enhanced RichTextBox that supports ink input as well as input to ink systems. It is also a Unicode control that supports Unicode properties such as .Text .

Standard MSHFlexGrid, DataGrid, and several other controls also support Unicode.

See http://www.alanwood.net/unicode/geometric_shapes.html for characters similar to the one in question. You can basically ignore jibber-jabber about ANSI, Charset, etc. This is relevant, but not applicable here.

▮ 9646 ▮ 25AE BLACK VERTICAL RECTANGLE

+1
source

The reason it displays a question mark is because the character is not used in the font used. You need to install a font that supports BLACK VERTICAL RECTANGLE , such as Arial Unicode MS or Lucida Sans Unicode.

0
source

All Articles