Here goes...
Originally Posted by
Jumper
i posted similiar post on another forum but still no answer there so i'm trying here.
pagecode, threads, text-based controls, local(global), wide-character, multi-byte characters
can anyone please explain how these terms are dependent on each other ?
OK, first thing first, a pagecode is actually a codepage and a local is actually a locale.
my current understanding is that
wide-character/multi-byte characters are schemas for storing character codes and
pagecode maps some specific code to character glyph(font entry)...
Yes, that is pretty much correct. Consider the value 156. Using the 1252 (ansi Latin 1) codepage this value may map to one character while using the 50936 (simplified Chinese) codepage it will likely map to a totally different character.
Unicode aims to be a universal character set that contains characters for every script. Therefore it is not dependent on codepages. The value 156 maps to the same character wheter your computer is set up for Chinese or Portugese.
A locale holds various language and format settings. For example consider we want today's date in short format.
If we pass a US locale to GetDateFormat() we will get:
6-30-04
However, if we pass a UK locale to GetDateFormat() we will get:
30-6-04
You can see the Locale Information page for more details on what a windows locale can control.
A locale may also hold details on the currently used codepage. As well as Windows locales there is also C locales.
say, i have a text-based control and documentation says that it uses a local to output text OR it uses some pagecode for symbol translation...
so if i want to print each line of text in different language how is that possible?
...
which win32 objects are depend on pagecode and/or local and is this means that these object are limited to simultenouesly handling only 3 or 2 types of glyphes(languages)?
As mentioned previously, unicode can handle characters for every language (although you may not have appropriate fonts installed). If not using unicode, you can only use characters available in the current code page.
for example:
i want to write a program that reads a unicode file with a few line in different language, say UTF-8.
now, i know that there are routines which are
local based and
unicode based.
as i see it, if i use a
locale aware routine then the file won't be read properly because the
local translates character codes according to some
pagecode(global?) and it will be mapped to wrong glyphs... so i must use general unicode i/o functions...
so what are
local dependant function good for?
You're making this way too complex.
- Read the UTF-8 into a LPSTR.
- Convert to unicode using MultiByteToWideChar(CP_UTF8, ...);
- Use the resulting unicode string.
Sample code to add a UTF8 string to a list box.
Code:
void AddUTF8ToListBox(HWND hwndListBox, LPCSTR szUTF8)
{
WCHAR szW[1024];
if (0 != MultiByteToWideChar(CP_UTF8, 0, szUTF8, -1, szW, 1024))
{
SendMessageW(hwndListBox, LB_ADDSTRING, 0, (LPARAM) szW);
}
}
Note: Windows 95/98/ME does not support unicode so, on those platforms, you are stuck with using characters from the current code page or having to use owner drawn.