您的位置:首页 > 其它

Windows 2000/XP上如何调用GB18030字符

2010-02-08 23:57 253 查看
安装gb18030工具包。

下载:
http://www.microsoft.com/downloads/details.aspx?FamilyID=93295d9c-89fc-4cba-ab19-ee176ea61d04&displaylang=zh-cn
http://download.pchome.net/utility/lan/gbbig5/10802.html

Windows 2000/XP上为支持GB18030在c_g18030.dll和ms4bsp.dll上新增加的函数如下:
000011A1 1 0000 ExtTextOutL
000010BA 2 0001 Get4ByteCodePage
00001280 3 0002 GetTextExtentExPointL
0000135C 5 0003 GetTextExtentPoint
0000142F 4 0004 GetTextExtentPoint32L
00001502 6 0005 MessageBoxExL
00001649 7 0006 MessageBoxL
000010E2 8 0007 Set4ByteCodePage
00001629 9 0008 TextOutL
00034F53 1 0000 BytesToUnicode
00035476 2 0001 NlsDllCodePageTranslation
00035279 3 0002 UnicodeToBytes

该 GB18030 支持工具包包含如下内容:
- 字体文件 SimSun18030.ttc
- 代码页支持文件 c_g18030.dll (只安装在Windows 2000 系统中)
- 转换工具gbunicnv.exe
- 微软4字节字符集编码支持包ms4bsp.dll
支持包安装成功后,转换工具 (gbunicnv.exe) 和微软4字节字符集编码支持包 (ms4bsp.dll) 会被安装在系统的 Program Files/GB18030Tools 文件夹下。用户可通过 Windows 2000 或 Windows XP 中的中文内码(Unicode) 输入法输入所需的 GB18030 扩充的4字节汉字。
转换工具 gbunicnv.exe 的使用方法
==============================
该转换工具用来实现GB18030-2000和 Unicode 编码格式文件的相互转换。该工具所支持的文件格式为文本文件(.txt)和HTML文件(.html)。gbunicnv.exe 的使用方法如下:
1)图形模式。执行gbunicnv.exe时不带参数,则gbunicnv.exe 将以图形模式启动。
2)命令行模式。用法:gbunicnv.exe [/U|/G|/?|/H 文件名1 [文件名2]
/H 或 /?, 显示帮助信息。
/U 或 /u, 执行GB18030-2000 到 Unicode 编码格式的转换。
/G 或 /g, 执行 Unicode 到 GB18030-2000 编码格式的转换。

开发人员附注
===========
1.Windows API对GB18030-2000 的支持
下列 Windows API 提供对GB18030-2000 的支持。IsValidCodePage(), GetCPInfo(), MultiByteToWideChar() and WideCharToMultiByte().
具体说明如下:
1) IsValidCodePage(54936) returns TRUE.
2) GetCPInfo(54936, lpCPInfo) returns TRUE.
3) MultiByteToWideChar(54936, 0, lpMultiByteStr, cbMultiByte, lpWideCharStr, cchWideChar) 完成GB18030-2000 字符串 lpMultiByteStr 到 Unicode 字符串 lpWideCharStr 的转换。
4) WideCharToMultiByte(54936, 0, lpWideCharStr, cchWideChar, lpMultiByteStr, cbMultiByte, lpDefaultChar, lpUsedDefaultChar) 完成Unicode 字符串 lpWideCharStr 到 GB18030-2000 字符串 lpMultiByteStr 的转换。
2. GB18030 函数库
微软4字节字符集编码支持包 (MS4BSP- Microsoft 4-byte Character Set Encoding Support Package) 提供了六个函数,这六个函数支持多字节编码(多达4字节)的字符串。 这些API 是从Windows 95/98/Me 提供的WCHAR (Unicode) 函数集中精选出来的。函数名与相应的ANSI 和WCHAR(Unicode) 函数完全相同,只是后缀的’A’ 或’W’被’L’替代。这些函数的参数与相应的’A’版本函数的参数接口完全相同。该支持包可使基于936代码页的应用程序向GB18030 或其他4字节编码的转换更加快捷。
MS4BSP 在Windows XP 平台的实现是作为一个简单的动态连接库 – ms4bsp.dll。 每一函数都通过调用MultiByteToWideChar() 函数将任何多字节字符串输入参数转换为UTF-16编码格式,然后调用相应的 ‘W’ 版本的函数,返回该函数的输出参数。该动态连接库假设当前系统中存在相关的字体,输入法(IME) 和注册表的设置信息。
该函数集中的缺省4字节字符编码为54936 (GB18030-2000). 将来版本的MS4BL 可能支持其他4字节编码。
接口清单:
BOOL ExtTextOutL(
HDC hdc, // handle to DC
int X, // x-coordinate of reference point
int Y, // y-coordinate of reference point
UINT fuOptions, // text-output options
CONST RECT* lprc, // optional dimensions
LPCSTR lpString, // string
UINT cbCount, // number of characters in string
CONST INT* lpDx // array of spacing values
);
BOOL GetTextExtentExPointL(
HDC hdc, // handle to DC
LPCSTR lpszStr, // character string
int cchString, // number of characters
int nMaxExtent, // maximum width of formatted string
LPINT lpnFit, // maximum number of characters
LPINT alpDx, // array of partial string widths
LPSIZE lpSize // string dimensions
);
BOOL GetTextExtentPoint32L(
HDC hdc, // handle to DC
LPCSTR lpString, // text string
int cbString, // characters in string
LPSIZE lpSize // string size
);
Int MessageBoxL(
HWND hWnd, // handle to owner window
LPCSTR lpText, // text in message box
LPCSTR lpCaption, // message box title
UINT uType // message box style
);
Int MessageBoxExL(
HWND hWnd, // handle to owner window
LPCSTR lpText, // text in message box
LPCSTR lpCaption, // message box title
UINT uType, // message box style
WORD wLanguageId // language identifier
);
BOOL TextOutL(
HDC hdc, // handle to DC
int nXStart, // x-coordinate of starting position
int nYStart, // y-coordinate of starting position
LPCSTR lpString, // character string
int cbString // number of characters
);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: