| 117 | //--------------------------------------------------------------------------------------// |
| 118 | |
| 119 | BOOST_FILESYSTEM_DECL |
| 120 | void convert(const char* from, const char* from_end, std::wstring& to, const codecvt_type* cvt) |
| 121 | { |
| 122 | if (from == from_end) |
| 123 | return; |
| 124 | |
| 125 | BOOST_ASSERT(from != nullptr); |
| 126 | BOOST_ASSERT(from_end != nullptr); |
| 127 | |
| 128 | if (!cvt) |
| 129 | cvt = &fs::path::codecvt(); |
| 130 | |
| 131 | std::size_t buf_size = (from_end - from) * 3; // perhaps too large, but that's OK |
| 132 | |
| 133 | // dynamically allocate a buffer only if source is unusually large |
| 134 | if (buf_size > default_codecvt_buf_size) |
| 135 | { |
| 136 | std::unique_ptr< wchar_t[] > buf(new wchar_t[buf_size]); |
| 137 | convert_aux(from, from_end, buf.get(), buf.get() + buf_size, to, *cvt); |
| 138 | } |
| 139 | else |
| 140 | { |
| 141 | wchar_t buf[default_codecvt_buf_size]; |
| 142 | convert_aux(from, from_end, buf, buf + default_codecvt_buf_size, to, *cvt); |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | //--------------------------------------------------------------------------------------// |
| 147 | // convert const wchar_t* to string // |
no test coverage detected