2 * msvcrt.dll mbcs functions
4 * Copyright 1999 Alexandre Julliard
5 * Copyright 2000 Jon Griffths
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * Not currently binary compatible with win32. MSVCRT_mbctype must be
23 * populated correctly and the ismb* functions should reference it.
28 #include "msvcrt/mbctype.h"
29 #include "msvcrt/mbstring.h"
30 #include "msvcrt/stdlib.h"
31 #include "msvcrt/string.h"
32 #include "msvcrt/wctype.h"
34 #include "wine/unicode.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(msvcrt
);
39 unsigned char MSVCRT_mbctype
[257];
40 int MSVCRT___mb_cur_max
= 1;
42 static MSVCRT_wchar_t
msvcrt_mbc_to_wc(unsigned int ch
)
52 mbch
[0] = (ch
>> 8) & 0xff;
56 if (!MultiByteToWideChar(MSVCRT_current_lc_all_cp
, 0, mbch
, n_chars
, &chW
, 1))
58 WARN("MultiByteToWideChar failed on %x\n", ch
);
64 /*********************************************************************
65 * __p__mbctype (MSVCRT.@)
67 unsigned char* __p__mbctype(void)
69 return MSVCRT_mbctype
;
72 /*********************************************************************
73 * __p___mb_cur_max(MSVCRT.@)
75 int* __p___mb_cur_max(void)
77 return &MSVCRT___mb_cur_max
;
80 /*********************************************************************
83 unsigned int _mbsnextc(const unsigned char* str
)
85 if(MSVCRT___mb_cur_max
> 1 && MSVCRT_isleadbyte(*str
))
86 return *str
<< 8 | str
[1];
87 return *str
; /* ASCII CP or SB char */
90 /*********************************************************************
91 * _mbctolower(MSVCRT.@)
93 unsigned int _mbctolower(unsigned int c
)
95 if (MSVCRT_isleadbyte(c
))
97 FIXME("Handle MBC chars\n");
100 return tolower(c
); /* ASCII CP or SB char */
103 /*********************************************************************
104 * _mbctoupper(MSVCRT.@)
106 unsigned int _mbctoupper(unsigned int c
)
108 if (MSVCRT_isleadbyte(c
))
110 FIXME("Handle MBC chars\n");
113 return toupper(c
); /* ASCII CP or SB char */
116 /*********************************************************************
119 unsigned char* _mbsdec(const unsigned char* start
, const unsigned char* cur
)
121 if(MSVCRT___mb_cur_max
> 1)
122 return (char *)(_ismbstrail(start
,cur
-1) ? cur
- 2 : cur
-1);
124 return (char *)cur
- 1; /* ASCII CP or SB char */
127 /*********************************************************************
130 unsigned char* _mbsinc(const unsigned char* str
)
132 if(MSVCRT___mb_cur_max
> 1 && MSVCRT_isleadbyte(*str
))
133 return (unsigned char*)str
+ 2; /* MB char */
135 return (unsigned char*)str
+ 1; /* ASCII CP or SB char */
138 /*********************************************************************
141 unsigned char* _mbsninc(const unsigned char* str
, MSVCRT_size_t num
)
145 if(MSVCRT___mb_cur_max
> 1)
149 return (unsigned char*)str
;
151 return (unsigned char*)str
+ num
; /* ASCII CP */
154 /*********************************************************************
157 unsigned int _mbclen(const unsigned char* str
)
159 return MSVCRT_isleadbyte(*str
) ? 2 : 1;
162 /*********************************************************************
165 int MSVCRT_mblen(const char* str
, MSVCRT_size_t size
)
167 if (str
&& *str
&& size
)
169 if(MSVCRT___mb_cur_max
== 1)
170 return 1; /* ASCII CP */
172 return !MSVCRT_isleadbyte(*str
) ? 1 : (size
>1 ? 2 : -1);
177 /*********************************************************************
180 MSVCRT_size_t
_mbslen(const unsigned char* str
)
182 if(MSVCRT___mb_cur_max
> 1)
184 MSVCRT_size_t len
= 0;
187 str
+= MSVCRT_isleadbyte(*str
) ? 2 : 1;
192 return strlen(str
); /* ASCII CP */
195 /*********************************************************************
196 * _mbstrlen(MSVCRT.@)
198 MSVCRT_size_t
_mbstrlen(const char* str
)
200 if(MSVCRT___mb_cur_max
> 1)
202 MSVCRT_size_t len
= 0;
205 /* FIXME: According to the documentation we are supposed to test for
206 * multi-byte character validity. Whatever that means
208 str
+= MSVCRT_isleadbyte(*str
) ? 2 : 1;
213 return strlen(str
); /* ASCII CP */
216 /*********************************************************************
219 void _mbccpy(unsigned char* dest
, const unsigned char* src
)
222 if(MSVCRT___mb_cur_max
> 1 && MSVCRT_isleadbyte(*src
))
223 *dest
= *++src
; /* MB char */
225 ERR("failure.. is this ok?\n");
228 /*********************************************************************
231 unsigned char* _mbsncpy(unsigned char* dst
, const unsigned char* src
, MSVCRT_size_t n
)
235 if(MSVCRT___mb_cur_max
> 1)
237 unsigned char* ret
= dst
;
241 if (MSVCRT_isleadbyte(*src
++))
248 return strncpy(dst
, src
, n
); /* ASCII CP */
251 /*********************************************************************
252 * _mbsnbcpy(MSVCRT.@)
254 unsigned char* _mbsnbcpy(unsigned char* dst
, const unsigned char* src
, MSVCRT_size_t n
)
258 if(MSVCRT___mb_cur_max
> 1)
260 unsigned char* ret
= dst
;
261 while (*src
&& (n
-- > 1))
264 if (MSVCRT_isleadbyte(*src
++))
270 if (*src
&& n
&& !MSVCRT_isleadbyte(*src
))
272 /* If the last character is a multi-byte character then
273 * we cannot copy it since we have only one byte left
282 return strncpy(dst
, src
, n
); /* ASCII CP */
285 /*********************************************************************
288 int _mbscmp(const unsigned char* str
, const unsigned char* cmp
)
290 if(MSVCRT___mb_cur_max
> 1)
292 unsigned int strc
, cmpc
;
295 return *cmp
? -1 : 0;
298 strc
= _mbsnextc(str
);
299 cmpc
= _mbsnextc(cmp
);
301 return strc
< cmpc
? -1 : 1;
302 str
+=(strc
> 255) ? 2 : 1;
303 cmp
+=(strc
> 255) ? 2 : 1; /* equal, use same increment */
306 return strcmp(str
, cmp
); /* ASCII CP */
309 /*********************************************************************
310 * _mbsicoll(MSVCRT.@)
311 * FIXME: handle locales.
313 int _mbsicoll(const unsigned char* str
, const unsigned char* cmp
)
315 if(MSVCRT___mb_cur_max
> 1)
317 unsigned int strc
, cmpc
;
320 return *cmp
? -1 : 0;
323 strc
= _mbctolower(_mbsnextc(str
));
324 cmpc
= _mbctolower(_mbsnextc(cmp
));
326 return strc
< cmpc
? -1 : 1;
327 str
+=(strc
> 255) ? 2 : 1;
328 cmp
+=(strc
> 255) ? 2 : 1; /* equal, use same increment */
331 return strcasecmp(str
, cmp
); /* ASCII CP */
335 /*********************************************************************
338 int _mbsicmp(const unsigned char* str
, const unsigned char* cmp
)
340 if(MSVCRT___mb_cur_max
> 1)
342 unsigned int strc
, cmpc
;
345 return *cmp
? -1 : 0;
348 strc
= _mbctolower(_mbsnextc(str
));
349 cmpc
= _mbctolower(_mbsnextc(cmp
));
351 return strc
< cmpc
? -1 : 1;
352 str
+=(strc
> 255) ? 2 : 1;
353 cmp
+=(strc
> 255) ? 2 : 1; /* equal, use same increment */
356 return strcasecmp(str
, cmp
); /* ASCII CP */
359 /*********************************************************************
362 int _mbsncmp(const unsigned char* str
, const unsigned char* cmp
, MSVCRT_size_t len
)
367 if(MSVCRT___mb_cur_max
> 1)
369 unsigned int strc
, cmpc
;
374 return *cmp
? -1 : 0;
377 strc
= _mbsnextc(str
);
378 cmpc
= _mbsnextc(cmp
);
380 return strc
< cmpc
? -1 : 1;
381 inc
=(strc
> 255) ? 2 : 1; /* Equal, use same increment */
385 return 0; /* Matched len chars */
387 return strncmp(str
, cmp
, len
); /* ASCII CP */
390 /*********************************************************************
391 * _mbsnbcmp(MSVCRT.@)
393 int _mbsnbcmp(const unsigned char* str
, const unsigned char* cmp
, MSVCRT_size_t len
)
397 if(MSVCRT___mb_cur_max
> 1)
399 unsigned int strc
, cmpc
;
404 return *cmp
? -1 : 0;
407 if (MSVCRT_isleadbyte(*str
))
409 strc
=(len
>=2)?_mbsnextc(str
):0;
417 if (MSVCRT_isleadbyte(*cmp
))
418 cmpc
=(len
>=2)?_mbsnextc(cmp
):0;
422 return strc
< cmpc
? -1 : 1;
427 return 0; /* Matched len chars */
429 return strncmp(str
,cmp
,len
);
432 /*********************************************************************
433 * _mbsnicmp(MSVCRT.@)
435 * Compare two multibyte strings case insensitively to 'len' characters.
437 int _mbsnicmp(const unsigned char* str
, const unsigned char* cmp
, MSVCRT_size_t len
)
439 /* FIXME: No tolower() for mb strings yet */
440 if(MSVCRT___mb_cur_max
> 1)
442 unsigned int strc
, cmpc
;
446 return *cmp
? -1 : 0;
449 strc
= _mbctolower(_mbsnextc(str
));
450 cmpc
= _mbctolower(_mbsnextc(cmp
));
452 return strc
< cmpc
? -1 : 1;
453 str
+=(strc
> 255) ? 2 : 1;
454 cmp
+=(strc
> 255) ? 2 : 1; /* Equal, use same increment */
456 return 0; /* Matched len chars */
458 return strncasecmp(str
, cmp
, len
); /* ASCII CP */
461 /*********************************************************************
462 * _mbsnbicmp(MSVCRT.@)
464 int _mbsnbicmp(const unsigned char* str
, const unsigned char* cmp
, MSVCRT_size_t len
)
468 if(MSVCRT___mb_cur_max
> 1)
470 unsigned int strc
, cmpc
;
475 return *cmp
? -1 : 0;
478 if (MSVCRT_isleadbyte(*str
))
480 strc
=(len
>=2)?_mbsnextc(str
):0;
488 if (MSVCRT_isleadbyte(*cmp
))
489 cmpc
=(len
>=2)?_mbsnextc(cmp
):0;
492 strc
= _mbctolower(strc
);
493 cmpc
= _mbctolower(cmpc
);
495 return strc
< cmpc
? -1 : 1;
500 return 0; /* Matched len bytes */
502 return strncmp(str
,cmp
,len
);
505 /*********************************************************************
508 * Find a multibyte character in a multibyte string.
510 unsigned char* _mbschr(const unsigned char* s
, unsigned int x
)
512 if(MSVCRT___mb_cur_max
> 1)
519 return (unsigned char*)s
;
522 s
+= c
> 255 ? 2 : 1;
525 return strchr(s
, x
); /* ASCII CP */
528 /*********************************************************************
531 unsigned char* _mbsrchr(const unsigned char* s
, unsigned int x
)
533 if(MSVCRT___mb_cur_max
> 1)
536 unsigned char* match
=NULL
;
542 match
=(unsigned char*)s
;
545 s
+=(c
> 255) ? 2 : 1;
551 /*********************************************************************
554 * Find and extract tokens from strings
556 unsigned char* _mbstok(unsigned char *str
, const unsigned char *delim
)
558 MSVCRT_thread_data
*data
= msvcrt_get_thread_data();
561 if(MSVCRT___mb_cur_max
> 1)
566 if (!(str
= data
->mbstok_next
)) return NULL
;
568 while ((c
= _mbsnextc(str
)) && _mbschr(delim
, c
)) {
569 str
+= c
> 255 ? 2 : 1;
571 if (!*str
) return NULL
;
573 while ((c
= _mbsnextc(str
)) && !_mbschr(delim
, c
)) {
574 str
+= c
> 255 ? 2 : 1;
578 if (c
> 255) *str
++ = 0;
580 data
->mbstok_next
= str
;
583 return strtok(str
, delim
); /* ASCII CP */
586 /*********************************************************************
589 int MSVCRT_mbtowc(MSVCRT_wchar_t
*dst
, const char* str
, MSVCRT_size_t n
)
593 if(!MultiByteToWideChar(CP_ACP
, 0, str
, n
, dst
, 1))
595 /* return the number of bytes from src that have been used */
598 if(n
>= 2 && MSVCRT_isleadbyte(*str
) && str
[1])
603 /*********************************************************************
604 * _mbbtombc(MSVCRT.@)
606 unsigned int _mbbtombc(unsigned int c
)
608 if(MSVCRT___mb_cur_max
> 1 &&
609 ((c
>= 0x20 && c
<=0x7e) ||(c
>= 0xa1 && c
<= 0xdf)))
611 /* FIXME: I can't get this function to return anything
612 * different to what I pass it...
615 return c
; /* ASCII CP or no MB char */
618 /*********************************************************************
619 * _ismbbkana(MSVCRT.@)
621 int _ismbbkana(unsigned int c
)
623 /* FIXME: use lc_ctype when supported, not lc_all */
624 if(MSVCRT_current_lc_all_cp
== 932)
626 /* Japanese/Katakana, CP 932 */
627 return (c
>= 0xa1 && c
<= 0xdf);
632 /*********************************************************************
633 * _ismbcdigit(MSVCRT.@)
635 int _ismbcdigit(unsigned int ch
)
637 MSVCRT_wchar_t wch
= msvcrt_mbc_to_wc( ch
);
638 return (get_char_typeW( wch
) & C1_DIGIT
);
641 /*********************************************************************
642 * _ismbcgraph(MSVCRT.@)
644 int _ismbcgraph(unsigned int ch
)
646 MSVCRT_wchar_t wch
= msvcrt_mbc_to_wc( ch
);
647 return (get_char_typeW( wch
) & (C1_UPPER
| C1_LOWER
| C1_DIGIT
| C1_PUNCT
| C1_ALPHA
));
650 /*********************************************************************
651 * _ismbcalpha (MSVCRT.@)
653 int _ismbcalpha(unsigned int ch
)
655 MSVCRT_wchar_t wch
= msvcrt_mbc_to_wc( ch
);
656 return (get_char_typeW( wch
) & C1_ALPHA
);
659 /*********************************************************************
660 * _ismbclower (MSVCRT.@)
662 int _ismbclower(unsigned int ch
)
664 MSVCRT_wchar_t wch
= msvcrt_mbc_to_wc( ch
);
665 return (get_char_typeW( wch
) & C1_UPPER
);
668 /*********************************************************************
669 * _ismbcupper (MSVCRT.@)
671 int _ismbcupper(unsigned int ch
)
673 MSVCRT_wchar_t wch
= msvcrt_mbc_to_wc( ch
);
674 return (get_char_typeW( wch
) & C1_LOWER
);
677 /*********************************************************************
678 * _ismbcsymbol(MSVCRT.@)
680 int _ismbcsymbol(unsigned int ch
)
682 MSVCRT_wchar_t wch
= msvcrt_mbc_to_wc( ch
);
684 if (!GetStringTypeW(CT_CTYPE3
, &wch
, 1, &ctype
))
686 WARN("GetStringTypeW failed on %x\n", ch
);
689 return ((ctype
& C3_SYMBOL
) != 0);
692 /*********************************************************************
693 * _ismbcalnum (MSVCRT.@)
695 int _ismbcalnum(unsigned int ch
)
697 MSVCRT_wchar_t wch
= msvcrt_mbc_to_wc( ch
);
698 return (get_char_typeW( wch
) & (C1_ALPHA
| C1_DIGIT
));
701 /*********************************************************************
702 * _ismbcspace (MSVCRT.@)
704 int _ismbcspace(unsigned int ch
)
706 MSVCRT_wchar_t wch
= msvcrt_mbc_to_wc( ch
);
707 return (get_char_typeW( wch
) & C1_SPACE
);
710 /*********************************************************************
711 * _ismbcprint (MSVCRT.@)
713 int _ismbcprint(unsigned int ch
)
715 MSVCRT_wchar_t wch
= msvcrt_mbc_to_wc( ch
);
716 return (get_char_typeW( wch
) & (C1_UPPER
| C1_LOWER
| C1_DIGIT
| C1_PUNCT
| C1_ALPHA
| C1_SPACE
));
719 /*********************************************************************
720 * _ismbcpunct(MSVCRT.@)
722 int _ismbcpunct(unsigned int ch
)
724 MSVCRT_wchar_t wch
= msvcrt_mbc_to_wc( ch
);
725 return (get_char_typeW( wch
) & C1_PUNCT
);
728 /*********************************************************************
729 * _ismbchira(MSVCRT.@)
731 int _ismbchira(unsigned int c
)
733 /* FIXME: use lc_ctype when supported, not lc_all */
734 if(MSVCRT_current_lc_all_cp
== 932)
736 /* Japanese/Hiragana, CP 932 */
737 return (c
>= 0x829f && c
<= 0x82f1);
742 /*********************************************************************
743 * _ismbckata(MSVCRT.@)
745 int _ismbckata(unsigned int c
)
747 /* FIXME: use lc_ctype when supported, not lc_all */
748 if(MSVCRT_current_lc_all_cp
== 932)
751 return _ismbbkana(c
);
752 /* Japanese/Katakana, CP 932 */
753 return (c
>= 0x8340 && c
<= 0x8396 && c
!= 0x837f);
758 /*********************************************************************
759 * _ismbblead(MSVCRT.@)
761 int _ismbblead(unsigned int c
)
763 /* FIXME: should reference MSVCRT_mbctype */
764 return MSVCRT___mb_cur_max
> 1 && MSVCRT_isleadbyte(c
);
768 /*********************************************************************
769 * _ismbbtrail(MSVCRT.@)
771 int _ismbbtrail(unsigned int c
)
773 /* FIXME: should reference MSVCRT_mbctype */
774 return !_ismbblead(c
);
777 /*********************************************************************
778 * _ismbslead(MSVCRT.@)
780 int _ismbslead(const unsigned char* start
, const unsigned char* str
)
782 /* Lead bytes can also be trail bytes if caller messed up
783 * iterating through the string...
785 if(MSVCRT___mb_cur_max
> 1)
788 start
+= MSVCRT_isleadbyte(*str
) ? 2 : 1;
791 return MSVCRT_isleadbyte(*str
);
793 return 0; /* Must have been a trail, we skipped it */
796 /*********************************************************************
797 * _ismbstrail(MSVCRT.@)
799 int _ismbstrail(const unsigned char* start
, const unsigned char* str
)
801 /* Must not be a lead, and must be preceeded by one */
802 return !_ismbslead(start
, str
) && MSVCRT_isleadbyte(str
[-1]);
805 /*********************************************************************
808 unsigned char* _mbsset(unsigned char* str
, unsigned int c
)
810 unsigned char* ret
= str
;
812 if(MSVCRT___mb_cur_max
== 1 || c
< 256)
813 return _strset(str
, c
); /* ASCII CP or SB char */
815 c
&= 0xffff; /* Strip high bits */
817 while(str
[0] && str
[1])
823 str
[0] = '\0'; /* FIXME: OK to shorten? */
828 /*********************************************************************
829 * _mbsnbset(MSVCRT.@)
831 unsigned char* _mbsnbset(unsigned char *str
, unsigned int c
, MSVCRT_size_t len
)
833 unsigned char *ret
= str
;
838 if(MSVCRT___mb_cur_max
== 1 || c
< 256)
839 return _strnset(str
, c
, len
); /* ASCII CP or SB char */
841 c
&= 0xffff; /* Strip high bits */
843 while(str
[0] && str
[1] && (len
> 1))
851 /* as per msdn pad with a blank character */
858 /*********************************************************************
861 unsigned char* _mbsnset(unsigned char* str
, unsigned int c
, MSVCRT_size_t len
)
863 unsigned char *ret
= str
;
868 if(MSVCRT___mb_cur_max
== 1 || c
< 256)
869 return _strnset(str
, c
, len
); /* ASCII CP or SB char */
871 c
&= 0xffff; /* Strip high bits */
873 while(str
[0] && str
[1] && len
--)
879 str
[0] = '\0'; /* FIXME: OK to shorten? */
884 /*********************************************************************
885 * _mbsnccnt(MSVCRT.@)
886 * 'c' is for 'character'.
888 MSVCRT_size_t
_mbsnccnt(const unsigned char* str
, MSVCRT_size_t len
)
891 if(MSVCRT___mb_cur_max
> 1)
894 while(*str
&& len
-- > 0)
896 if(MSVCRT_isleadbyte(*str
))
909 return min(ret
, len
); /* ASCII CP */
912 /*********************************************************************
913 * _mbsnbcnt(MSVCRT.@)
914 * 'b' is for byte count.
916 MSVCRT_size_t
_mbsnbcnt(const unsigned char* str
, MSVCRT_size_t len
)
919 if(MSVCRT___mb_cur_max
> 1)
921 const unsigned char* xstr
= str
;
922 while(*xstr
&& len
-- > 0)
924 if (MSVCRT_isleadbyte(*xstr
++))
930 return min(ret
, len
); /* ASCII CP */
934 /*********************************************************************
935 * _mbsnbcat(MSVCRT.@)
937 unsigned char* _mbsnbcat(unsigned char* dst
, const unsigned char* src
, MSVCRT_size_t len
)
939 if(MSVCRT___mb_cur_max
> 1)
943 if (MSVCRT_isleadbyte(*dst
++)) {
947 /* as per msdn overwrite the lead byte in front of '\0' */
953 while (*src
&& len
--) *dst
++ = *src
++;
957 return strncat(dst
, src
, len
); /* ASCII CP */
961 /*********************************************************************
964 unsigned char* _mbsncat(unsigned char* dst
, const unsigned char* src
, MSVCRT_size_t len
)
966 if(MSVCRT___mb_cur_max
> 1)
971 if (MSVCRT_isleadbyte(*dst
++))
974 while (*src
&& len
--)
977 if(MSVCRT_isleadbyte(*src
++))
983 return strncat(dst
, src
, len
); /* ASCII CP */
987 /*********************************************************************
990 unsigned char* _mbslwr(unsigned char* s
)
994 if (MSVCRT___mb_cur_max
> 1)
1000 c
= _mbctolower(_mbsnextc(s
));
1001 /* Note that I assume that the size of the character is unchanged */
1015 /*********************************************************************
1018 unsigned char* _mbsupr(unsigned char* s
)
1022 if (MSVCRT___mb_cur_max
> 1)
1028 c
= _mbctoupper(_mbsnextc(s
));
1029 /* Note that I assume that the size of the character is unchanged */
1043 /*********************************************************************
1044 * _mbsspn (MSVCRT.@)
1046 MSVCRT_size_t
_mbsspn(const unsigned char* string
, const unsigned char* set
)
1048 const unsigned char *p
, *q
;
1050 for (p
= string
; *p
; p
++)
1052 if (MSVCRT_isleadbyte(*p
))
1054 for (q
= set
; *q
; q
++)
1058 if ((*p
== *q
) && (p
[1] == q
[1]))
1066 for (q
= set
; *q
; q
++)
1073 /*********************************************************************
1074 * _mbscspn(MSVCRT.@)
1076 MSVCRT_size_t
_mbscspn(const unsigned char* str
, const unsigned char* cmp
)
1078 if (MSVCRT___mb_cur_max
> 1)
1079 FIXME("don't handle double character case\n");
1080 return strcspn(str
, cmp
);
1083 /*********************************************************************
1084 * _mbsrev (MSVCRT.@)
1086 unsigned char* _mbsrev(unsigned char* str
)
1088 int i
, len
= _mbslen(str
);
1089 unsigned char *p
, *temp
=MSVCRT_malloc(len
*2);
1094 /* unpack multibyte string to temp buffer */
1096 for(i
=0; i
<len
; i
++)
1098 if (MSVCRT_isleadbyte(*p
))
1110 /* repack it in the reverse order */
1112 for(i
=len
-1; i
>=0; i
--)
1114 if(MSVCRT_isleadbyte(temp
[i
*2]))
1130 /*********************************************************************
1131 * _mbspbrk (MSVCRT.@)
1133 unsigned char* _mbspbrk(const unsigned char* str
, const unsigned char* accept
)
1135 const unsigned char* p
;
1139 for(p
= accept
; *p
; p
+= (MSVCRT_isleadbyte(*p
)?2:1) )
1142 if( !MSVCRT_isleadbyte(*p
) || ( *(p
+1) == *(str
+1) ) )
1143 return (unsigned char*)str
;
1145 str
+= (MSVCRT_isleadbyte(*str
)?2:1);