MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / toString

Method toString

src/common/isc_file.cpp:1754–1795  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1752 }
1753
1754 bool toString(UINT codePage, AbstractString& str)
1755 {
1756 if (m_len16 == 0)
1757 {
1758 str.resize(0);
1759 return true;
1760 }
1761
1762 BOOL defaultCharUsed = FALSE;
1763 LPBOOL pDefaultCharUsed = &defaultCharUsed;
1764 if (codePage == CP_UTF8 || codePage == CP_UTF7)
1765 pDefaultCharUsed = NULL;
1766
1767 WCHAR* utf16Buffer = m_utf16.begin();
1768
1769 char* utf8Buffer = str.getBuffer(str.capacity());
1770 int len8 = WideCharToMultiByte(codePage, 0, utf16Buffer, m_len16,
1771 utf8Buffer, str.capacity(), NULL, pDefaultCharUsed);
1772
1773 if (len8 == 0 || defaultCharUsed)
1774 {
1775 DWORD err = GetLastError();
1776 if (err != ERROR_INSUFFICIENT_BUFFER)
1777 return false;
1778
1779 len8 = WideCharToMultiByte(codePage, 0, utf16Buffer, m_len16, NULL, 0, NULL, pDefaultCharUsed);
1780 if (len8 == 0 || defaultCharUsed)
1781 return false;
1782
1783 utf8Buffer = str.getBuffer(len8);
1784
1785 len8 = WideCharToMultiByte(codePage, 0, utf16Buffer, m_len16, utf8Buffer, len8,
1786 NULL, pDefaultCharUsed);
1787 }
1788
1789 if (len8 == 0 || defaultCharUsed)
1790 return false;
1791
1792 str.resize(len8);
1793
1794 return true;
1795 }
1796
1797 WCHAR* getBuffer()
1798 {

Callers 2

ISC_systemToUtf8Function · 0.45
ISC_utf8ToSystemFunction · 0.45

Calls 4

resizeMethod · 0.45
beginMethod · 0.45
getBufferMethod · 0.45
capacityMethod · 0.45

Tested by

no test coverage detected