| 1723 | {} |
| 1724 | |
| 1725 | bool fromString(UINT codePage, const AbstractString& str) |
| 1726 | { |
| 1727 | if (str.isEmpty()) |
| 1728 | { |
| 1729 | m_len16 = 0; |
| 1730 | return true; |
| 1731 | } |
| 1732 | |
| 1733 | int bufSize = m_utf16.getCapacity(); |
| 1734 | WCHAR* utf16Buffer = m_utf16.getBuffer(bufSize); |
| 1735 | m_len16 = MultiByteToWideChar(codePage, 0, str.c_str(), str.length(), utf16Buffer, bufSize); |
| 1736 | |
| 1737 | if (m_len16 == 0) |
| 1738 | { |
| 1739 | DWORD err = GetLastError(); |
| 1740 | if (err != ERROR_INSUFFICIENT_BUFFER) |
| 1741 | return false; |
| 1742 | |
| 1743 | bufSize = MultiByteToWideChar(codePage, 0, str.c_str(), str.length(), NULL, 0); |
| 1744 | if (bufSize == 0) |
| 1745 | return false; |
| 1746 | |
| 1747 | utf16Buffer = m_utf16.getBuffer(bufSize); |
| 1748 | m_len16 = MultiByteToWideChar(codePage, 0, str.c_str(), str.length(), utf16Buffer, bufSize); |
| 1749 | } |
| 1750 | |
| 1751 | return (m_len16 != 0); |
| 1752 | } |
| 1753 | |
| 1754 | bool toString(UINT codePage, AbstractString& str) |
| 1755 | { |
no test coverage detected