| 27 | wchar_t *wstr; |
| 28 | size_t wlen; |
| 29 | ustring2wstr(const ustring &src){ |
| 30 | wlen = 0; |
| 31 | for (size_t i = 0; i < src.length(); ++i) |
| 32 | { |
| 33 | if (src[i] < unicode_helpers::SMP_TOP) wlen++; |
| 34 | else wlen += 2; |
| 35 | } |
| 36 | wstr = new wchar_t[wlen+1]; |
| 37 | wstr[wlen] = L'\0'; |
| 38 | |
| 39 | size_t wi = 0; |
| 40 | for (size_t i = 0; i < src.length(); ++i) |
| 41 | { |
| 42 | if (src[i] < unicode_helpers::SMP_TOP) |
| 43 | { |
| 44 | wstr[wi++] = (wchar_t)src[i]; |
| 45 | } |
| 46 | else |
| 47 | { |
| 48 | unichar high, low; |
| 49 | unichar_to_surrogate_pair(src[i], high, low); |
| 50 | wstr[wi++] = (wchar_t)high; |
| 51 | wstr[wi++] = (wchar_t)low; |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | ~ustring2wstr() |
| 56 | { |
| 57 | delete[] wstr; |
nothing calls this directly
no test coverage detected