8f73145d9d
These functions have a dependency on the "VT Redirected" versions of VkKeyScanW, MapVirtualKeyW and GetKeyState. Those implementations depend on the service locator and therefore the entire interactivity stack. This meant that anybody depending on just Types had to pull in **the entire host** worth of dependencies (!). Since these functions are only used in places where we have or are testing interactivity, it makes sense to consolidate them here.
40 lines
1,018 B
C++
40 lines
1,018 B
C++
/*++
|
|
Copyright (c) Microsoft Corporation
|
|
|
|
Module Name:
|
|
- convert.hpp
|
|
|
|
Abstract:
|
|
- Defines functions for converting between A and W text strings.
|
|
Largely taken from misc.h.
|
|
|
|
Author:
|
|
- Mike Griese (migrie) 30-Oct-2017
|
|
|
|
--*/
|
|
|
|
#pragma once
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
enum class CodepointWidth : BYTE
|
|
{
|
|
Narrow,
|
|
Wide,
|
|
Ambiguous, // could be narrow or wide depending on the current codepage and font
|
|
Invalid // not a valid unicode codepoint
|
|
};
|
|
|
|
[[nodiscard]] std::wstring ConvertToW(const UINT codepage,
|
|
const std::string_view source);
|
|
|
|
[[nodiscard]] std::string ConvertToA(const UINT codepage,
|
|
const std::wstring_view source);
|
|
|
|
[[nodiscard]] size_t GetALengthFromW(const UINT codepage,
|
|
const std::wstring_view source);
|
|
|
|
CodepointWidth GetQuickCharWidth(const wchar_t wch) noexcept;
|
|
|
|
wchar_t Utf16ToUcs2(const std::wstring_view charData);
|