On Tuesday 15 March 2005 00:43, Juan Lang wrote:
Raphael wrote:
- if (!*str) { /** TODO: check *str validity */
- return -1; /** _MBC_ILLEGAL */
- }
- if (start == str && MSVCRT_isleadbyte(*str)) {
- return 1; /** _MBC_LEAD */
- }
- if (start == str && MSVCRT_isleadbyte(str[-1])) {
- return 2; /**_MBC_TRAIL */
- }
- return 0; /** _MBC_SINGLE */
Cool. How about patching mbctype.h with these constants too?
--Juan
Try 2 :)
Changelog: - implement _mbsbtype (bug 1831)
This One without tests improvements as they failed on wine (as wine don't seems to support chineese) :(
the test patch for people who want to test: Index: dlls/msvcrt/tests/string.c =================================================================== RCS file: /home/wine/wine/dlls/msvcrt/tests/string.c,v retrieving revision 1.2 diff -u -r1.2 string.c --- dlls/msvcrt/tests/string.c 4 May 2004 04:13:06 -0000 1.2 +++ dlls/msvcrt/tests/string.c 5 Apr 2005 20:33:36 -0000 @@ -22,6 +22,8 @@ #include "winbase.h" #include <string.h> #include <stdlib.h> +#include "mbctype.h" +#include "mbstring.h"
static void* (*pmemcpy)(void *, const void *, size_t n); static int* (*pmemcmp)(void *, const void *, size_t n); @@ -34,6 +36,10 @@ { void *mem; static const char xilstring[]="c:/xilinx"; + + static const char s_chin[] = "\326\354"; /* ZHU1 for mbcs tests */ + static const char s_jap[] = "A\x9A\x8B\xE0\xEF\xF0xXyYzZ"; + int nLen=strlen(xilstring); HMODULE hMsvcrt = LoadLibraryA("msvcrt.dll"); ok(hMsvcrt != 0, "LoadLibraryA failed\n"); @@ -46,6 +52,24 @@ ok(mem != NULL, "memory not allocated for size 0\n"); strcpy((char*)mem,xilstring); pmemcpy((char*)mem+5, mem,nLen+1); - ok(pmemcmp((char*)mem+5,xilstring, nLen) == 0, - "Got result %s\n",(char*)mem+5); + ok(pmemcmp((char*)mem+5,xilstring, nLen) == 0, "Got result %s\n",(char*)mem+5); + + /** + * http://www.geocities.com/yongweiwu/multibyte.htm + * http://home.a03.itscom.net/tsuzu/programing/tips06_2.htm + */ + + _setmbcp(936); /* Japanese */ + ok( 0 == _ismbblead(s_jap[1]), "0 == _ismbblead(s_jap[1]), was %d\n", _ismbblead(s_jap[1]) ); + + _setmbcp(932); /* Chinese GBK */ + ok( 4 == _ismbblead(s_chin[1]), "4 == _ismbblead(s_chin[1]), was %d\n", _ismbblead(s_chin[1]) ); + ok( 0 == _ismbslead(s_chin, &s_chin[1]), "0 == _ismbslead(s_chin, &s_chin[1]), was %d\n", _ismbslead(s_chin, &s_chin[1])); + + ok( 2 == strlen(s_chin), "2 == strlen(s_chin), was %d\n", strlen(s_chin)); + ok( 1 == _mbslen(s_chin), "1 == _mbslen(s_chin), was %d\n", _mbslen(s_chin)); + + ok( _MBC_LEAD == _mbsbtype(s_chin, 0), "_MBC_LEAD == _mbsbtype(s_chin, 0), was %d\n", _mbsbtype(s_chin, 0) ); + ok( _MBC_TRAIL == _mbsbtype(s_chin, 1), "_MBC_TRAIL == _mbsbtype(s_chin, 1), was %d\n", _mbsbtype(s_chin, 1) ); + }
Regards, Raphael