void CConfigAppearance::AddFontName(std::wstring_view Name) // // // { if (Name.size() >= LF_FACESIZE) // // // return; CComboBox *pFontList = static_cast<CComboBox*>(GetDlgItem(IDC_FONT)); pFontList->AddString(Name.data()); if (m_strFont == Name) pFontList->SelectString(0, Name.data()); }
size_t split_line(SplitStringLine *result, unsigned wid, std::wstring_view str, size_t offset, unsigned options) { str.remove_prefix(offset); const wchar_t *s = str.data(); size_t slen = str.length(); size_t cur = 0; // Current position unsigned curwid = 0;// Used screen width for (;;) { if (cur >= slen) { result->begin = offset; result->len = slen; result->wid = curwid; return (offset + slen); } if (!(options & SPLIT_NEWLINE_AS_SPACE) && s[cur] == L'\n') { result->begin = offset; result->len = cur; result->wid = curwid; return (offset + cur + 1); // Skip the newline character } unsigned w = ucs_width (s[cur]); if (curwid + w > wid) { break; } curwid += w; ++cur; } // Not the whold string. Neither has a newline character been encountered // Now scan backward to find a proper line-breaking point unsigned extra_skip = 0; if (!(options & SPLIT_CUT_WORD)) { unsigned xcur = cur; for (;;) { if (xcur == 0) { // This means that a single word is longer than a line. We have to split it break; } if ((!ucs_isalnum (s[xcur-1]) || !ucs_isalnum (s[xcur])) && allow_line_end (s[xcur-1]) && allow_line_beginning (s[xcur])) { cur = xcur; break; } curwid -= ucs_width (s[--xcur]); } while (cur+extra_skip+1<slen && s[cur+extra_skip]==L' ') { ++extra_skip; } } result->begin = offset; result->len = cur; result->wid = curwid; return (offset + cur + extra_skip); }
std::unordered_map<std::wstring_view, std::wstring_view> splitData(const std::wstring_view &data) { std::unordered_map<std::wstring_view, std::wstring_view> out; size_t start = 0; for (size_t end = data.find(L";", start); end != std::wstring::npos; start = end + 1, end = data.find(L";", start)) { if (start == end) { end = data.size(); } const std::wstring_view tmp(data.data() + start, end - start); const auto pos = tmp.find(L"="); out[tmp.substr(0, pos)] = tmp.substr(pos + 1); // tLog << L"'" << tmp.substr(0, pos) << L"' = '" << tmp.substr(pos + 1) << L"'"; } return out; }
bool operator()(std::wstring_view lhs, std::wstring_view rhs) const { if (_wcsicmp(lhs.data(), rhs.data()) < 0) return true; return false; }
static expected<random_access_stream, hresult_error> create_on_file(std::wstring_view file_path, ABI::Windows::Storage::FileAccessMode acc){ return detail::convert_to_rich_interface<random_access_stream>(com_create_resource<ABI::Windows::Storage::Streams::IRandomAccessStream>([&](ABI::Windows::Storage::Streams::IRandomAccessStream** ptr){return ::CreateRandomAccessStreamOnFile(file_path.data(), acc, ABI::Windows::Storage::Streams::IID_IRandomAccessStream, reinterpret_cast<void**>(ptr));}), _T(__FUNCTION__)); }
std::string utf16_to_utf8(std::wstring_view wtext) { std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter; std::string text = converter.to_bytes(wtext.data()); return text; }