Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: support for multi-character constants #9

Open
grkblood13 opened this issue Jun 16, 2022 · 2 comments
Open

feature request: support for multi-character constants #9

grkblood13 opened this issue Jun 16, 2022 · 2 comments

Comments

@grkblood13
Copy link

grkblood13 commented Jun 16, 2022

I tried to update the code to support the full international morse code standard with what I thought were single characters (minus CH) to the unordered map kMorseCode in ggmorse.cpp, but I got multi-character character constant warnings when compiling and bigger problems when running. Perhaps this is why you left these out to begin with. The symbols in question, some which are shared by other non-latin symbols and pose another interesting issue, are:

    { "0101",    'Ä',  },
    { "01101",   'À',  },
    { "1111",    'CH', },
    { "00100",   'É',  },
    { "11011",   'Ñ',  },
    { "1110",    'Ö',  },
    { "0011",    'Ü',  },

I tried converting the unordered map to strings instead of characters, but it just turned into a big mess. I'm thinking that's the way it probably should be though in order to fully support all possibilities.

@ggerganov
Copy link
Owner

Multi-byte characters are currently not supported by ggmorse.
I think the simplest solution that you can do is keep the internal map as it is and extend it with a few extra single-byte characters and then perform the mapping to your multi-byte characters outside of ggmorse.

For example:

// in ggmorse.cpp
const TAlphabet kMorseCode = {
    { "0101",    128,  },
    { "01101",   129,  },
    { "1111",    130,  },
    { "00100",   131,  },
    { "11011",   132,  },
    { "1110",    133,  },
    { "0011",    134,  },
    { "01",      'A',  },
    { "1000",    'B',  },
    { "1010",    'C',  },
    { "100",     'D',  },
...
};

```c++
// in your code
// use this map to convert the resulting single-byte text to multi-byte text
const std::unordered_map<char, std::string> {
    { 128,   "Ä",  },
    { 129,   "À",  },
    { 130,   "CH", },
    { 131,   "É",  },
    { 132,   "Ñ",  },
    { 133,   "Ö",  },
    { 134,   "Ü",  },
    { 'A',   "A",  },
    { 'B',   "B",  },
    { 'C',   "C",  },
    { 'D',   "D",  },
...
};

@grkblood13
Copy link
Author

Maybe a flag could be implemented that would output the morse code sequences instead of mapping them to characters. That way, a follow-on program could handle the mapping with whatever characters are needed without having to worry about updating the mapping inside of ggmorse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants