C
C#10mo ago
SeiOkami

✅ How do I replace each character with a character that corresponds to the standard English layout?

There is a string with the characters "ЙЦУКЕН". It corresponds to the "QWERTY" string of the standard English layout. Is it possible to replace each character with the corresponding character of the standard English layout without creating my own dictionaries?
11 Replies
exokem
exokem10mo ago
you need to map the characters somehow what is it specifically you are trying to do?
SeiOkami
SeiOkamiOP10mo ago
Let's imagine a simple console application. It takes each string from string[] args. And replaces each character (e.g., "Й") with the English layout character ("Q") corresponding to the key. I start the application and pass the string "myapp -йцукен" The application gives me the result "qwerty".
exokem
exokem10mo ago
the simplest solution is a dictionary it could be possible to do something with keycodes and system layouts but I don't know the specific possibility
SeiOkami
SeiOkamiOP10mo ago
Yeah, but that's exactly what I want to avoid. I hope there are more universal options
Tinister
Tinister10mo ago
How are the characters related to each other?
exokem
exokem10mo ago
position on the keyboard the physical keypress that produces them so from the actual key input events (from polling input) you could maybe do this based on the keycode rather than the character, but you would still need mappings of the keycode to the chars you want
SeiOkami
SeiOkamiOP10mo ago
In theory, Windows has a dictionary. I'd like to refer to it
No description
SeiOkami
SeiOkamiOP10mo ago
For example, go through all connected keyboard layouts. And just then output all the variants
Tinister
Tinister10mo ago
This might be a win32 function or possibly registry I know there's utilities that let you "remap" keys, you could look at how those work but only read those mappings
exokem
exokem10mo ago
I found this from winforms that seems to provide the installed input languages, but I don't think it provides the key mappings: https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.inputlanguage.installedinputlanguages?view=windowsdesktop-8.0
exokem
exokem10mo ago
there is also this from user32 (accessible with dllimport): https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getkeyboardlayout
GetKeyboardLayout function (winuser.h) - Win32 apps
Retrieves the active input locale identifier (formerly called the keyboard layout).
Want results from more Discord servers?
Add your server