Home > Articles > Programming > Visual Basic

Like this article? We recommend

Like this article? We recommend

Speaking the Same Language (in This Book!)

Before going any further, I want to make sure everyone is on the same page regarding many of the basic terms in the book. As with describing any technology, I will be using a great deal of jargon to explain concepts. I hesitate to call this section a glossary because I will be explaining some of the terms at length. You might not yet understand how to actually make use of these terms, but at least you will know what I am talking about in later chapters!

Internationalization (i18N)

Internationalization, also known as globalization, is the process that converts an existing application to be globally aware. In an internationalized application, all the issues specific to other locales—such as changes in culture, convention, the input of data, the display of data, and the user interface elements—will work properly and will not be considered incorrect or offensive to the local user. Internationalization does not require an application's user interface to be in a different language from its original form (although that is the next step in the process, which is described further in the definitions of translation and localization). Internationalization does require that the user can type in data in her own language and to see it displayed properly in that language.

Internationalization is often abbreviated to i18N, which literally refers to the I at the beginning of the word, the N at the end, and the 18 letters in between (a lowercase i is used because an uppercase I can be mistaken for a lowercase l). Although i18N is not commonly used in Microsoft's documentation (it cannot be found at all in searches of current version of MSDN), in the world outside of Microsoft, i18N is the de facto term used to describe the concept. (Interestingly, inside Microsoft, i18N is used quite frequently in discussions about internationalization.)

In most cases, an internationalized application depends heavily on the default local settings of the machine on which it is running. This functionality enables me to write my application on a Japanese platform (probably using the localized version of Visual Basic); deploy it to customers in France, Hungary, or Korea; and expect the application to work properly. My users' French, Hungarian, and Korean data will display properly. Those users will be able to use their local keyboard or input method editor (IME, defined later in this chapter), and all dates, numbers, and currency values will be handled using the definitions in their regional settings.

i18N is the cornerstone of every other topic in this book, and understanding it is a prerequisite to understanding everything that follows. Many applications will never need to be converted beyond the step of internationalization, and, for Visual Basic 6, internationalization is one of the only readily supported scenarios.

Multinationalization (M18N)

If this book is describing a process, multinationalization is not necessarily a step that your Visual Basic applications need to take. Multinationalization is best defined as a large step beyond a merely internationalized application that brings your application to the world. A multinationalized application, as the name implies, brings the world to your application! A Visual Basic application can handle multiple languages, even crossing the code page barrier to support those different languages side by side. It does not depend on the machine's default language settings or user preferences to handle this data input and display.

The term multinationalization is one that I never saw used before I started using it in 1998. Therefore, I am going to borrow from the i18N example and refer to multinationalization as M18N throughout this book.

Visual Basic 6.0 does not support M18N out of the box because VB is so heavily tied to the default system code page and the user's regional settings. In all fairness, however, the strong need for this scenario was not created until almost a year after VB 6.0 shipped, with the introduction of Office 2000. With its Unicode support in all the major applications such as Word, Excel, and Access, and with excellent multiple code page support in programs such as FrontPage, Office 2000 was the first brick in the wall. The second was the Office 2000 multilanguage packs (sometimes known as langpacks), which were designed to allow the user interface elements of Office to display in any language at all, without degrading functionality. You can see in Figures 1 and 2 that, if you have CD2 of the multilanguage packs, you can change the Office user interface to Japanese. When you have done this, you will have a Japanese user interface in Office 2000 applications. For example, Access 2000 will now show a Japanese user interface, as seen in Figure 3.

(It was, in fact, my own frustrations in trying to get VB6 add-ins designed for Office 2000 to work in this type of scenario that first led to my interest in M18N.)

Figure 1 The User Interface tab of the Office 2000 Language Settings applet enables you to choose a Japanese user interface for your Office applications.

Figure 2 The Enabled Languages tab enables you to choose what languages will be available for use in Microsoft Office.

Figure 3 Aside from the language difference, the U.S. English version of Access 2000 looks exactly the same as the localized Japanese product.

Even Office 2000 fell a little bit short of its goal, requiring a separate "South Asia" edition to handle some of the specific details for Thai, Vietnamese, and Hindi. But the capability became even more widespread with the release of Windows 2000, which is designed to support any language at all on any version of the product. Windows 2000 has its own version of the Office 2000 langpacks: the multilanguage user interface, or MUI. With this product, which can be installed over the English version of Windows 2000, it is possible to completely change the operating system's user interface from English to any locale you like. The MUI completely divorces the UI from the default system code page and the regional settings.

In fact, in Windows 2000, the goal of completely separating all three of these items is closer to being achieved than in any prior version of Windows. Figure 4 shows a U.S. Windows 2000 Server with a French UI and Russian regional settings. Figure 5 shows that same Windows 2000 Server with a Turkish UI and Korean regional settings. Note that although the user interface language changes, the behavior of dates is based on the regional settings (which you can see in the lower-right corner when the cursor hovers over the clock). Figure 6 shows where to set these three settings (the regional settings, the user interface language, and the default system language).

NOTE

Before you get too excited about the capabilities of Windows 2000 MUI or the Office 2000 multilanguage pack, keep in mind that they are not included with Windows 2000 and Office 2000 by default. They are separate products that you must purchase and install. Note that these are add-ins to the original product that rely on the concept of worldwide EXE, an issue discussed later in this chapter.

Figure 4 Parlez-vous français? Hopefully, you do speak French if you are using the French user interface with the Windows 2000 MUI.

Figure 5 Even with a Turkish user interface, all it takes is Korean regional settings to cause dates and times to be shown in Korean when you hover over the date in the system tray.

Figure 6 Use the Regional Options Control Panel applet to set the user interface language and the default system code.

Unfortunately, this new scenario took Visual Basic by surprise. It created a need that VB simply is not designed to fulfill (at least, not without some help). In many senses, large parts of this book and especially of M18N are intended to help. The sections of the book related to multinationalization are an attempt to empower everyone to bring some of the same functionality of Windows 2000 and Office 2000 to their applications. Customers will very reasonably expect Microsoft's premier and best-selling rapid application development (RAD) tool to support the scenario that Office 2000 and Windows 2000 (more than half of Microsoft's revenue) have in large part created.

Translation

Translation is the process of representing the text of your application (the dialogs, menus, alerts, documentation, and so forth) in another language. Interestingly, the process of translation itself is becoming something that has even been automated with some success. Although a Web site such as http://babelfish.altavista.com is not perfect, it is very easy to get the overall meaning of text from its translations. However, there is a lot more to the process than the simple mapping of one word to another, as simple attempts to translate the same sentence repeatedly from French to English and back to French again will prove. That difference is best captured in our next term: localization.

Localization

Put simply, localization is when you move beyond the simple mapping of the translation process to make sure that the wording covers local customs and conventions. The process must also involve knowledge of the culture and expectations of speakers of both the source and target languages so that the process can effectively translate the differences between all these factors in a way that allows for total understanding. It is obvious why localization is so much more difficult than mere translation. A good localizer is key to producing a product (be it a software application or a book) that will succeed in other languages.

A good example of a localized VB application is the Replication Conflict Viewer that ships with Microsoft SQL Server 7.0 and Jet 4.0. The Swedish version of this application is shown in Figure 7. Other add-ins for Microsoft Office 2000 that were created in VB (and that are localized into between 20 and 26 languages) include the Word Web Page Wizard, the Office Web Chart Wizard, the MCE Cube Wizard, the Outlook Team Folders component, and the MultiSelect Objects add-in.

Figure 7 If you have the Swedish version of Office 2000 and want to view and resolve your replication conflicts, there is a wizard created in Visual Basic that will display them for you.

CAUTION

Be careful not to insult a potential localizer by not fully explaining the distinction I am making here between translator and localizer. Many people who do an excellent job in the localization process are not using this exact terminology. It would seem that some of these terms make up a language of their own!

On the other hand, if you explain the concept properly, a localizer will probably be flattered by the distinction.

Code Pages

If you have ever used the Chr$() or Asc() functions in Visual Basic, you have already used code pages. A code page is a simple mapping between numbers (known as code points) and characters or glyphs. This standard allows the letter A to be code point 65, for example. The mapping enables you to represent all the languages that reside within that code page.

All the regular, single-byte code pages have 256 characters in them. The first 128 code points on all code pages are always the same; in a small bit of provincialism, the basic characters for English can be universally rendered on any code page. The other 128 characters are reserved for characters needed by other languages on the code page, such as [gb] for German or ç for French. Obviously, only so many languages can fit into each code page, which is where things start to get difficult. Those 256 code points are the same actual numbers, and it is up to the program you are running to properly choose the code page to use for interpreting them. To see this in action, you can open any of the 14 files in the code pages subdirectory on the CD in notepad.exe. These files represent the 14 Windows code pages. Only one of them will look right; the other 13 will look like gibberish (which one depends on your operating system's language). You can see the names of these different code pages in Table 1.

Table 1 Windows Code Pages

Code Page

Windows Constant

Windows Code Page Name

1250

CP_EASTEUROPE

Central European (Latin 2)

1251

CP_RUSSIAN

Cyrillic

1252

CP_WESTEUROPE

Western European (Latin 1)

1253

CP_GREEK

Greek

1254

CP_TURKISH

Turkish (Latin 5)

1255

CP_HEBREW

Hebrew

1256

CP_ARABIC

Arabic

1257

CP_BALTIC

Baltic Rim

1258

CP_VIETNAMESE

Vietnamese

874

CP_THAI

Thai

932

CP_JAPAN

Japanese

936

CP_CHINA

Simplified Chinese

949

CP_KOREA

Korean

950

CP_TAIWAN

Traditional Chinese

The last four code pages in Table 1 are not limited to 256 characters—these Far East languages each have thousands of different characters. Each of these code pages uses double-byte character set (DBCS) encoding. All the rules about an application having to know the code page to use still apply because there is nothing intrinsic in a bunch of numbers that would tell you what language they are in.

Every Windows platform, even Windows 2000, has a single default code page that is used in most applications, including Visual Basic. Windows 2000 is the first member of the Windows family that has enabled you to change the default system code page.

The entire system of code pages gets more complex when you have to deal with all the alternative encodings for Far East languages, not to mention code pages for DOS, Macintosh, various ISO code pages, and more. The entire system is slowly being replaced by an encoding that is meant to include all languages. The ISO calls it 10646-1, and most of the rest of us know it as Unicode.

Unicode: UCS-2, UCS-4, UTF-7, UTF-8, UTF-16, and So On

Unicode was in many ways the answer to all the problems inherent in code pages. The Unicode standard is a 16-bit character set designed to encode all known characters. In practice, even 216 or 65536 characters are still not enough, which is why the 2.0 version of the Unicode standard defines a surrogate range. This range of characters turns into a pointer to the next 2 bytes, thus allowing a 32-bit character set. There are currently no languages in the surrogate range, and even Windows 2000 has only minimal support for the surrogate range. (It's hard to test surrogates because there are no characters in the surrogate range, yet.)

The Unicode standard is carefully kept in line with the ISO/IEC international encoding standard 10646-1. The changes to make this possible took place between versions 1.0 and 1.1 of the standard, and since then the Unicode Consortium has been very careful to stay in line with the ISO standard.

It is important to note that Unicode itself is not really an encoding; in fact, Unicode uses several different encodings that can represent it. In the world of Microsoft products, when you are talking about Unicode, you are generally talking about UCS-2/UTF-16, which is the standard that literally uses 2 bytes per character. This is what products such as SQL Server and Jet refer to when they mention Unicode, and it is the standard for strings that are used by COM and by the "W" or wide functions on Windows NT.

What the Heck Are the "W" and "A" Functions?

When Microsoft moved its operating systems to 32-bit, every API call that takes a string was given two separate APIs, one with an "A" suffix and one with a "W" suffix. The suffix choices are not really very intuitive, however. The "A" refers to ANSI but is really the multibyte character set (MBCS) version of the function, which assumes that the default code page for the system will be used. The "W" version, on the other hand, refers to "Wide" and assumes that the strings sent to this function will be Unicode strings in UCS-2/UTF-16 format. If you use the API Viewer in Visual Basic (see Figure 8), you will notice that it is always assuming that you want to use the "A" versions of the Windows API calls

Figure 8 Visual Basic's API Viewer lists only the "A" versions of API calls.

Outside of Microsoft products and on the World Wide Web, usually when someone refers to Unicode he is talking about UTF-8. In fact, most databases (such as Oracle) seem to prefer UTF-8 to UTF-16 when it comes to encoding characters. To Windows, UTF-8 is just another multibyte encoding, one that just so happens to cover every language in the world. This is important to keep in mind when you need to translate information or data between your application and these other sources. One of the biggest uses of UTF-8 is in Extensible Markup Language (XML), whose default encoding is indeed UTF-8.

Glyphs

A glyph is simply a picture that represents a character; glyphs are the end result that users see once you deal with all of the issues with code pages and code points. There can be a great deal of variation with glyphs, even when they are meant to represent the same character, as you can see in Figure 9.

Figure 9 How many ways can you say the letter A? There were more than 50 different ways on this machine!

Fonts

A font is a collection of glyphs that can map all of the various code points to the appropriate glyphs, as needed. It has been possible to create Unicode fonts since Windows first shipped 32-bit versions, and most font-making tools actually produce Unicode fonts, even if they represent characters only on a specific code page. Fonts can be very important when you need to display data, and they will be discussed in several parts of the book.

Strings and BSTRs

If you have been using Visual Basic at all, you know what a string is, but one of the things that VB hides from developers is how strings are represented and stored in memory. They are defined as BSTRs. The definition for a BSTR is simple: It is a wide-char (Unicode) pointer to a block of memory with the following characteristics:

  • A special contract for creation (allocation)

  • A special contract for destruction (deallocation)

  • An API (a set of functions), and prefixed by a length encoding that represents the size of the string

All of the details about BSTRs are handled automatically by Visual Basic, so, in theory, you do not need to worry about them.

In practice, because you are reading this book, you actually do need to worry about BSTRs and how they can be used. I will therefore be discussing BSTRs throughout the book.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020