trunk/src/osd/strconv.cpp
r255115 | r255116 | |
109 | 109 | int osd_uchar_from_osdchar(UINT32 *uchar, const char *osdchar, size_t count) |
110 | 110 | { |
111 | 111 | WCHAR wch; |
| 112 | CPINFO cp; |
112 | 113 | |
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 | |
| 126 | error: |
| 127 | *uchar = 0; |
| 128 | return static_cast<int>(count); |
119 | 129 | } |
120 | 130 | |
121 | 131 | #else |