Converts a string from UTF-8 to the system charset.
| 1837 | |
| 1838 | // Converts a string from UTF-8 to the system charset. |
| 1839 | void ISC_utf8ToSystem(Firebird::AbstractString& str) |
| 1840 | { |
| 1841 | if (str.isEmpty()) |
| 1842 | return; |
| 1843 | |
| 1844 | #if defined(WIN_NT) |
| 1845 | WideCharBuffer<MAX_PATH> wBuffer; |
| 1846 | |
| 1847 | if (!wBuffer.fromString(CP_UTF8, str) || !wBuffer.toString(CP_ACP, str)) |
| 1848 | { |
| 1849 | DWORD err = GetLastError(); |
| 1850 | status_exception::raise( |
| 1851 | Arg::Gds(isc_bad_conn_str) << Arg::Gds(isc_transliteration_failed) << |
| 1852 | Arg::Windows(err)); |
| 1853 | } |
| 1854 | |
| 1855 | #elif defined(HAVE_ICONV_H) |
| 1856 | iConv().utf8ToSystem.convert(str); |
| 1857 | #endif |
| 1858 | } |
| 1859 | |
| 1860 | |
| 1861 | // Escape Unicode characters from a string |
no test coverage detected