Skip to content

Commit

Permalink
rearrange codetable
Browse files Browse the repository at this point in the history
  • Loading branch information
windytan committed May 15, 2022
1 parent d0c1b2d commit 0679116
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
41 changes: 19 additions & 22 deletions src/rdsstring.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,26 @@ namespace {

// EN 50067:1998, Annex E (pp. 73-76)
// plus UCS-2 control codes
std::string getRDSCharString(uint16_t code) {
std::string getRDSCharString(uint8_t code) {
static const std::array<std::string, 256> codetable_G0({
" ", " ", " ", "0", "@", "P", "", "p", "á", "â", "ª", "º", "Á", "Â", "Ã", "ã",
" ", " ", "!", "1", "A", "Q", "a", "q", "à", "ä", "α", "¹", "À", "Ä", "Å", "å",
" ", " ", "\"","2", "B", "R", "b", "r", "é", "ê", "©", "²", "É", "Ê", "Æ", "æ",
" ", " ", "#", "3", "C", "S", "c", "s", "è", "ë", "", "³", "È", "Ë", "Œ", "œ",
" ", " ", "¤", "4", "D", "T", "d", "t", "í", "î", "Ǧ", "±", "Í", "Î", "ŷ", "ŵ",
" ", " ", "%", "5", "E", "U", "e", "u", "ì", "ï", "ě", "İ", "Ì", "Ï", "Ý", "ý",
" ", " ", "&", "6", "F", "V", "f", "v", "ó", "ô", "ň", "ń", "Ó", "Ô", "Õ", "õ",
" ", " ", "'", "7", "G", "W", "g", "w", "ò", "ö", "ő", "ű", "Ò", "Ö", "Ø", "ø",
" ", " ", "(", "8", "H", "X", "h", "x", "ú", "û", "π", "µ", "Ú", "Û", "Þ", "þ",
" ", " ", ")", "9", "I", "Y", "i", "y", "ù", "ü", "", "¿", "Ù", "Ü", "Ŋ", "ŋ",
"\n"," ", "*", ":", "J", "Z", "j", "z", "Ñ", "ñ", "£", "÷", "Ř", "ř", "Ŕ", "ŕ",
" ", " ", "+", ";", "K", "[", "k", "{", "Ç", "ç", "$", "°", "Č", "č", "Ć", "ć",
" ", " ", ",", "<", "L", "\\","l", "|", "Ş", "ş", "", "¼", "Š", "š", "Ś", "ś",
"\r"," ", "-", "=", "M", "]", "m", "}", "β", "ǧ", "", "½", "Ž", "ž", "Ź", "ź",
" ", " ", ".", ">", "N", "", "n", "¯", "¡", "ı", "", "¾", "Ð", "đ", "Ŧ", "ŧ",
" ", "\u00AD","/", "?", "O", "_", "o", " ", "IJ", "ij", "", "§", "Ŀ", "ŀ", "ð", " " });

size_t row = code & 0xF;
size_t col = code >> 4;

return codetable_G0[row * 16 + col];
" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "\n"," ", " ", "\r"," ", " ",
" ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "\u00AD",
" ", "!", "\"","#", "¤", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?",
"@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O",
"P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "\\","]", "", "_",
"", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o",
"p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "¯", " ",
"á", "à", "é", "è", "í", "ì", "ó", "ò", "ú", "ù", "Ñ", "Ç", "Ş", "β", "¡", "IJ",
"â", "ä", "ê", "ë", "î", "ï", "ô", "ö", "û", "ü", "ñ", "ç", "ş", "ǧ", "ı", "ij",
"ª", "α", "©", "", "Ǧ", "ě", "ň", "ő", "π", "", "£", "$", "", "", "", "",
"º", "¹", "²", "³", "±", "İ", "ń", "ű", "µ", "¿", "÷", "°", "¼", "½", "¾", "§",
"Á", "À", "É", "È", "Í", "Ì", "Ó", "Ò", "Ú", "Ù", "Ř", "Č", "Š", "Ž", "Ð", "Ŀ",
"Â", "Ä", "Ê", "Ë", "Î", "Ï", "Ô", "Ö", "Û", "Ü", "ř", "č", "š", "ž", "đ", "ŀ",
"Ã", "Å", "Æ", "Œ", "ŷ", "Ý", "Õ", "Ø", "Þ", "Ŋ", "Ŕ", "Ć", "Ś", "Ź", "Ŧ", "ð",
"ã", "å", "æ", "œ", "ŵ", "ý", "õ", "ø", "þ", "ŋ", "ŕ", "ć", "ś", "ź", "ŧ", " "});

return codetable_G0[code];
}

} // namespace
Expand Down
6 changes: 3 additions & 3 deletions src/rdsstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ namespace redsea {
class RDSChar {
public:
RDSChar() = default;
explicit RDSChar(uint16_t _code) : code_(_code) {};
explicit RDSChar(uint8_t _code) : code_(_code) {};

uint16_t getCode() const { return code_; };
uint8_t getCode() const { return code_; };
bool isSequential() const { return is_sequential_; };
void setSequential(bool is) { is_sequential_ = is; }

private:
uint16_t code_ { 0 };
uint8_t code_ { 0 };
bool is_sequential_ { false };
};

Expand Down

0 comments on commit 0679116

Please sign in to comment.