Previous 199869 Revisions Next

r46604 Wednesday 23rd March, 2016 at 01:15:46 UTC by Brad Hughes
Get max char size from ANSI codepage instead of IsDBCSLeadChar()
[src/osd]strconv.cpp

trunk/src/osd/strconv.cpp
r255115r255116
109109int osd_uchar_from_osdchar(UINT32 *uchar, const char *osdchar, size_t count)
110110{
111111   WCHAR wch;
112   CPINFO cp;
112113
113   count = MIN(count, IsDBCSLeadByte(*osdchar) ? 2 : 1);
114   if (MultiByteToWideChar(CP_ACP, 0, osdchar, (DWORD)count, &wch, 1) != 0)
115      *uchar = wch;
116   else
117      *uchar = 0;
118   return (int) count;
114   if (!GetCPInfo(CP_ACP, &cp))
115      goto error;
116
117   // The multibyte char can't be bigger than the max character size
118   count = MIN(count, cp.MaxCharSize);
119
120   if (!MultiByteToWideChar(CP_ACP, 0, osdchar, static_cast<DWORD>(count), &wch, 1) != 0)
121      goto error;
122
123   *uchar = wch;
124   return static_cast<int>(count);
125
126error:
127   *uchar = 0;
128   return static_cast<int>(count);
119129}
120130
121131#else


Previous 199869 Revisions Next


© 1997-2024 The MAME Team