2016-03-25 01:19:46 -05:00
|
|
|
|
/**
|
2016-03-24 13:01:20 -05:00
|
|
|
|
* Marlin 3D Printer Firmware
|
|
|
|
|
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
|
|
|
*
|
|
|
|
|
* Based on Sprinter and grbl.
|
|
|
|
|
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2015-03-11 04:55:16 -05:00
|
|
|
|
#ifndef UTF_MAPPER_H
|
|
|
|
|
#define UTF_MAPPER_H
|
|
|
|
|
|
|
|
|
|
#include "language.h"
|
|
|
|
|
|
2015-07-31 00:03:15 -05:00
|
|
|
|
#if ENABLED(DOGLCD)
|
2015-03-17 05:23:44 -05:00
|
|
|
|
#define HARDWARE_CHAR_OUT u8g.print
|
2015-03-11 04:55:16 -05:00
|
|
|
|
#else
|
2015-03-17 05:23:44 -05:00
|
|
|
|
#define HARDWARE_CHAR_OUT lcd.write
|
2015-03-11 04:55:16 -05:00
|
|
|
|
#endif
|
|
|
|
|
|
2015-07-31 00:03:15 -05:00
|
|
|
|
#if DISABLED(SIMULATE_ROMFONT) && ENABLED(DOGLCD)
|
2017-04-21 09:05:29 -05:00
|
|
|
|
#if ENABLED(DISPLAY_CHARSET_ISO10646_1) \
|
|
|
|
|
|| ENABLED(DISPLAY_CHARSET_ISO10646_5) \
|
|
|
|
|
|| ENABLED(DISPLAY_CHARSET_ISO10646_KANA) \
|
|
|
|
|
|| ENABLED(DISPLAY_CHARSET_ISO10646_GREEK) \
|
|
|
|
|
|| ENABLED(DISPLAY_CHARSET_ISO10646_TR)
|
2016-11-19 12:23:53 -06:00
|
|
|
|
#define MAPPER_ONE_TO_ONE
|
2015-03-13 08:26:58 -05:00
|
|
|
|
#endif
|
|
|
|
|
#else // SIMULATE_ROMFONT
|
2016-04-27 00:25:50 -05:00
|
|
|
|
#if DISPLAY_CHARSET_HD44780 == JAPANESE
|
2015-07-31 00:03:15 -05:00
|
|
|
|
#if ENABLED(MAPPER_C2C3)
|
2015-03-11 04:55:16 -05:00
|
|
|
|
const PROGMEM uint8_t utf_recode[] =
|
|
|
|
|
{ // 0 1 2 3 4 5 6 7 8 9 a b c d e f This is fair for symbols
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0x20,0x3F,0xEC,0xED,0x3F,0x5C,0x7C,0x3F,0x22,0x63,0x61,0x7F,0x3F,0x3F,0x52,0xB0, // c2a
|
2016-11-26 04:23:25 -06:00
|
|
|
|
//' ' ¢ £ l " c a « R
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0xDF,0x3F,0x32,0x33,0x27,0xE4,0xF1,0xA5,0x2C,0x31,0xDF,0x7E,0x3F,0x3F,0x3F,0x3F, // c2b but relatively bad for letters.
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// ° 2 3 ` N p . , 1 ° »
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0x3F,0x3F,0x3F,0x3F,0xE1,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F, // c38
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// ä
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0xEF,0x78,0x3F,0x3F,0x3F,0x3F,0xF5,0x3F,0x3F,0xE2, // c39 missing characters display as '?'
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// ö x ü ß
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0x3F,0x3F,0x3F,0x3F,0xE1,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F, // c3a
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// ä
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0x3F,0xEE,0x3F,0x3F,0x3F,0x3F,0xEF,0xFD,0x3F,0x3F,0x3F,0x3F,0xF5,0x3F,0x3F,0x3F // c3b
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// n ö ÷ ü
|
2015-03-11 04:55:16 -05:00
|
|
|
|
};
|
2015-07-31 00:03:15 -05:00
|
|
|
|
#elif ENABLED(MAPPER_E382E383)
|
2015-03-11 04:55:16 -05:00
|
|
|
|
const PROGMEM uint8_t utf_recode[] =
|
|
|
|
|
{ // 0 1 2 3 4 5 6 7 8 9 a b c d e f
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0x3D,0xB1,0xB1,0xA8,0xB2,0xA9,0xB3,0xAA,0xB4,0xAB,0xB5,0xB6,0xB6,0xB7,0xB7,0xB8, // e382a Please test and correct
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// = ア ア ィ イ ゥ ウ ェ エ ォ オ ガ ガ キ キ ク
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0xB8,0xB9,0xB9,0xBA,0xBA,0xBB,0xBB,0xBC,0xBC,0xBD,0xBD,0xBE,0xBE,0xBF,0xBF,0xC0, // e382b
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// ク ケ ケ コ コ サ サ シ シ ス ス セ セ ソ ソ タ
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0xC0,0xC1,0xC1,0xC2,0xC2,0xC2,0xC3,0xC3,0xC4,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA, // e3838
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// タ チ チ ッ ッ ッ テ テ ト ト ナ ニ ヌ ネ ノ ハ
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0xCA,0xCA,0xCB,0xCB,0xCB,0xCC,0xCC,0xCC,0xCD,0xCD,0xCD,0xCE,0xCE,0xCE,0xCF,0xD0, // e3839
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// ハ ハ ヒ ヒ ヒ フ フ フ ヘ ヘ ヘ ホ ホ ホ マ ミ
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0xD1,0xD2,0xD3,0xD4,0xD4,0xD5,0xD5,0xAE,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDC, // e383a
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// ム メ モ ャ ャ ユ ユ ョ ヨ ラ リ ル レ ロ ワ ワ
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0xEC,0xA7,0xA6,0xDD,0xCC,0x3F,0x3F,0x3F,0x3F,0x3F,0xA6,0xA5,0xB0,0xA4,0xA4,0x3F // e383b
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// ヰ ヱ ヲ ン フ ? ? ? ? ? ヲ ・ ー ヽ ヽ ?
|
2015-03-11 04:55:16 -05:00
|
|
|
|
};
|
2015-07-31 00:03:15 -05:00
|
|
|
|
#elif ENABLED(MAPPER_D0D1)
|
2016-05-14 17:06:09 -05:00
|
|
|
|
#error "Cyrillic on a JAPANESE display makes no sense. There are no matching symbols."
|
2015-03-11 04:55:16 -05:00
|
|
|
|
#endif
|
|
|
|
|
|
2016-04-27 00:25:50 -05:00
|
|
|
|
#elif DISPLAY_CHARSET_HD44780 == WESTERN
|
2015-07-31 00:03:15 -05:00
|
|
|
|
#if ENABLED(MAPPER_C2C3)
|
2015-03-11 04:55:16 -05:00
|
|
|
|
const PROGMEM uint8_t utf_recode[] =
|
|
|
|
|
{ // 0 1 2 3 4 5 6 7 8 9 a b c d e f This is relative complete.
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0x20,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0x22,0xA9,0xAA,0xAB,0x3F,0x3F,0xAE,0x3F, // c2a ¡¢£¤¥¦§¨©ª«¬®¯
|
2016-11-26 04:23:25 -06:00
|
|
|
|
//' ' ¡ ¢ £ ¤ ¥ ¦ § " © ª « ? ? ® ?
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0xB0,0xB1,0xB2,0xB3,0x27,0xB5,0xB6,0xB7,0x2C,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, // c2b °±²³´µ¶·¸¹º»¼½¾¿
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// ° ± ³ ² ? µ ¶ · , ¹ º » ¼ ½ ¾ ¿
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, // c38 ÀÁÃÄÅÆÇÈÉÊËÌÍÎÏ
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, // c39 ÐÑÓÔÕÖ×ØÙÚÛÜÝÞß
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, // c3a àáãäåæçèéêëìíîï
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// à á â ã ä å æ ç è é ê ë ì í î ï
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF // c3b ðñóôõö÷øùúûüýþÿ
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ
|
2015-03-11 04:55:16 -05:00
|
|
|
|
};
|
2015-07-31 00:03:15 -05:00
|
|
|
|
#elif ENABLED(MAPPER_D0D1)
|
2015-03-11 04:55:16 -05:00
|
|
|
|
#define MAPPER_D0D1_MOD
|
|
|
|
|
const PROGMEM uint8_t utf_recode[] =
|
|
|
|
|
{//0 1 2 3 4 5 6 7 8 9 a b c d e f
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0x41,0x80,0x42,0x92,0x81,0x45,0x82,0x83,0x84,0x85,0x4B,0x86,0x4D,0x48,0x4F,0x87, // d0a
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// A Б B Г Д E Ж З И Й K Л M H O П
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0x50,0x43,0x54,0x88,0xD8,0x58,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x62,0x8F,0xAC,0xAD, // d0b
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// P C T У Ф X Ч ч Ш Щ Ъ Ы b Э Ю Я
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0x61,0x36,0x42,0x92,0x81,0x65,0x82,0xB3,0x84,0x85,0x6B,0x86,0x4D,0x48,0x6F,0x87, // d18
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// a 6 B Г Д e Ж ³ И Й k Л M H o П
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0x70,0x63,0x54,0x79,0xD8,0x78,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x62,0x8F,0xAC,0xAD // d19
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// p c T y Ф x Ч ч Ш Щ Ъ Ы b Э Ю Я
|
2015-03-11 04:55:16 -05:00
|
|
|
|
};
|
2015-07-31 00:03:15 -05:00
|
|
|
|
#elif ENABLED(MAPPER_E382E383)
|
2016-05-14 17:06:09 -05:00
|
|
|
|
#error "Katakana on a WESTERN display makes no sense. There are no matching symbols."
|
2015-03-11 04:55:16 -05:00
|
|
|
|
#endif
|
|
|
|
|
|
2016-04-27 00:25:50 -05:00
|
|
|
|
#elif DISPLAY_CHARSET_HD44780 == CYRILLIC
|
2015-07-31 00:03:15 -05:00
|
|
|
|
#if ENABLED(MAPPER_D0D1)
|
2015-03-11 04:55:16 -05:00
|
|
|
|
#define MAPPER_D0D1_MOD
|
|
|
|
|
// it is a Russian alphabet translation
|
2017-04-21 21:42:27 -05:00
|
|
|
|
// except 0401 --> 0xA2 = Ё, 0451 --> 0xB5 = ё
|
2015-03-11 04:55:16 -05:00
|
|
|
|
const PROGMEM uint8_t utf_recode[] =
|
2017-04-21 21:42:27 -05:00
|
|
|
|
{ 0x41,0xA0,0x42,0xA1,0xE0,0x45,0xA3,0xA4, // unicode U+0400 to U+047f
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// A Б->Ё B Г Д E Ж З // 0 Ѐ Ё Ђ Ѓ Є Ѕ І Ї
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0xA5,0xA6,0x4B,0xA7,0x4D,0x48,0x4F,0xA8, // Ј Љ Њ Ћ Ќ Ѝ Ў Џ
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// И Й K Л M H O П // 1 А Б В Г Д Е Ж З
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0x50,0x43,0x54,0xA9,0xAA,0x58,0xE1,0xAB, // И Й К Л М Н О П
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// P C T У Ф X Ч ч // 2 Р С Т У Ф Х Г Ч
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0xAC,0xE2,0xAD,0xAE,0x62,0xAF,0xB0,0xB1, // Ш Щ Ъ Ы Ь Э Ю Я
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// Ш Щ Ъ Ы b Э Ю Я // 3 а б в г д е ж з
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0x61,0xB2,0xB3,0xB4,0xE3,0x65,0xB6,0xB7, // и й к л м н о п
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// a б->ё в г д e ж з // 4 р с т у ф х ц ч
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0x6F,0xBE, // ш щ ъ ы ь э ю я
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// и й к л м н o п // 5 ѐ ё ђ ѓ є ѕ і ї
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0x70,0x63,0xBF,0x79,0xE4,0x78,0xE5,0xC0, // ј љ њ ћ ќ ѝ ў џ
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// p c т y ф x ц ч // 6 Ѡ ѡ Ѣ ѣ Ѥ ѥ Ѧ ѧ
|
2017-04-21 21:42:27 -05:00
|
|
|
|
0xC1,0xE6,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7 // Ѫ ѩ Ѫ ѫ Ѭ ѭ Ѯ ѯ
|
2016-11-26 04:23:25 -06:00
|
|
|
|
// ш щ ъ ы ь э ю я // 7 Ѱ ѱ Ѳ ѳ Ѵ ѵ Ѷ ѷ
|
|
|
|
|
}; // ѻ ѹ Ѻ ѻ Ѽ ѽ Ѿ ѿ
|
2015-07-31 00:03:15 -05:00
|
|
|
|
#elif ENABLED(MAPPER_C2C3)
|
2016-05-14 17:06:09 -05:00
|
|
|
|
#error "Western languages on a CYRILLIC display makes no sense. There are no matching symbols."
|
2015-07-31 00:03:15 -05:00
|
|
|
|
#elif ENABLED(MAPPER_E382E383)
|
2016-05-14 17:06:09 -05:00
|
|
|
|
#error "Katakana on a CYRILLIC display makes no sense. There are no matching symbols."
|
2015-03-11 04:55:16 -05:00
|
|
|
|
#endif
|
2015-03-13 13:45:10 -05:00
|
|
|
|
#else
|
2016-05-13 07:10:23 -05:00
|
|
|
|
#error "Something went wrong in the setting of DISPLAY_CHARSET_HD44780"
|
2016-04-27 00:25:50 -05:00
|
|
|
|
#endif // DISPLAY_CHARSET_HD44780
|
2015-03-13 08:26:58 -05:00
|
|
|
|
#endif // SIMULATE_ROMFONT
|
2015-03-11 04:55:16 -05:00
|
|
|
|
|
2016-07-12 12:42:42 -05:00
|
|
|
|
#if ENABLED(MAPPER_C2C3)
|
2015-10-13 05:55:16 -05:00
|
|
|
|
|
2016-11-24 00:54:21 -06:00
|
|
|
|
char charset_mapper(const char c) {
|
2015-10-13 05:55:16 -05:00
|
|
|
|
static uint8_t utf_hi_char; // UTF-8 high part
|
|
|
|
|
static bool seen_c2 = false;
|
2015-03-11 04:55:16 -05:00
|
|
|
|
uint8_t d = c;
|
2017-05-21 05:58:03 -05:00
|
|
|
|
if (d >= 0x80u) { // UTF-8 handling
|
|
|
|
|
if (d >= 0xC0u && !seen_c2) {
|
2017-04-21 21:42:27 -05:00
|
|
|
|
utf_hi_char = d - 0xC2u;
|
2015-03-11 04:55:16 -05:00
|
|
|
|
seen_c2 = true;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2015-10-13 05:51:34 -05:00
|
|
|
|
else if (seen_c2) {
|
2017-04-21 21:42:27 -05:00
|
|
|
|
d &= 0x3Fu;
|
2016-07-10 20:59:04 -05:00
|
|
|
|
#ifndef MAPPER_ONE_TO_ONE
|
|
|
|
|
HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
|
|
|
|
|
#else
|
|
|
|
|
HARDWARE_CHAR_OUT((char)(0x80u + (utf_hi_char << 6) + d)) ;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
HARDWARE_CHAR_OUT('?');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
HARDWARE_CHAR_OUT((char) c );
|
|
|
|
|
}
|
|
|
|
|
seen_c2 = false;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-12 07:35:02 -06:00
|
|
|
|
#elif ENABLED(MAPPER_C2C3_TR)
|
|
|
|
|
|
|
|
|
|
// the C2C3-mapper extended for the 6 altered symbols from C4 and C5 range.
|
|
|
|
|
|
|
|
|
|
char charset_mapper(const char c) {
|
|
|
|
|
static uint8_t utf_hi_char; // UTF-8 high part
|
2017-04-21 21:42:27 -05:00
|
|
|
|
static bool seen_c2 = false,
|
|
|
|
|
seen_c4 = false,
|
|
|
|
|
seen_c5 = false;
|
2016-12-12 07:35:02 -06:00
|
|
|
|
uint8_t d = c;
|
2017-05-21 05:58:03 -05:00
|
|
|
|
if (d >= 0x80u) { // UTF-8 handling
|
|
|
|
|
if (d == 0xC4u) { seen_c4 = true; return 0; }
|
|
|
|
|
else if (d == 0xC5u) { seen_c5 = true; return 0; }
|
|
|
|
|
else if (d >= 0xC0u && !seen_c2) {
|
2017-04-21 21:42:27 -05:00
|
|
|
|
utf_hi_char = d - 0xC2u;
|
2016-12-12 07:35:02 -06:00
|
|
|
|
seen_c2 = true;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else if (seen_c4) {
|
|
|
|
|
switch(d) {
|
2017-04-21 21:42:27 -05:00
|
|
|
|
case 0x9Eu: d = 0xD0u; break;
|
|
|
|
|
case 0x9Fu: d = 0xF0u; break;
|
|
|
|
|
case 0xB0u: d = 0xDDu; break;
|
|
|
|
|
case 0xB1u: d = 0xFDu; break;
|
2016-12-12 07:35:02 -06:00
|
|
|
|
default: d = '?';
|
|
|
|
|
}
|
|
|
|
|
HARDWARE_CHAR_OUT((char)d) ;
|
|
|
|
|
}
|
|
|
|
|
else if (seen_c5) {
|
|
|
|
|
switch(d) {
|
2017-04-21 21:42:27 -05:00
|
|
|
|
case 0x9Eu: d = 0xDEu; break;
|
|
|
|
|
case 0x9Fu: d = 0xFEu; break;
|
2016-12-12 07:35:02 -06:00
|
|
|
|
default: d = '?';
|
|
|
|
|
}
|
|
|
|
|
HARDWARE_CHAR_OUT((char)d) ;
|
|
|
|
|
}
|
|
|
|
|
else if (seen_c2) {
|
2017-04-21 21:42:27 -05:00
|
|
|
|
d &= 0x3Fu;
|
2016-12-12 07:35:02 -06:00
|
|
|
|
#ifndef MAPPER_ONE_TO_ONE
|
|
|
|
|
HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
|
|
|
|
|
#else
|
|
|
|
|
HARDWARE_CHAR_OUT((char)(0x80u + (utf_hi_char << 6) + d)) ;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
HARDWARE_CHAR_OUT('?');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
HARDWARE_CHAR_OUT((char) c );
|
|
|
|
|
}
|
|
|
|
|
seen_c2 = seen_c4 = seen_c5 = false;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-10 20:59:04 -05:00
|
|
|
|
#elif ENABLED(MAPPER_CECF)
|
|
|
|
|
|
2016-11-24 00:54:21 -06:00
|
|
|
|
char charset_mapper(const char c) {
|
2016-07-10 20:59:04 -05:00
|
|
|
|
static uint8_t utf_hi_char; // UTF-8 high part
|
|
|
|
|
static bool seen_ce = false;
|
|
|
|
|
uint8_t d = c;
|
2017-05-21 05:58:03 -05:00
|
|
|
|
if (d >= 0x80) { // UTF-8 handling
|
|
|
|
|
if (d >= 0xC0 && !seen_ce) {
|
2017-04-21 21:42:27 -05:00
|
|
|
|
utf_hi_char = d - 0xCE;
|
2016-07-10 20:59:04 -05:00
|
|
|
|
seen_ce = true;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else if (seen_ce) {
|
2017-04-21 21:42:27 -05:00
|
|
|
|
d &= 0x3F;
|
2015-03-11 04:55:16 -05:00
|
|
|
|
#ifndef MAPPER_ONE_TO_ONE
|
2015-10-13 05:51:34 -05:00
|
|
|
|
HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
|
2015-03-11 04:55:16 -05:00
|
|
|
|
#else
|
2015-10-13 05:51:34 -05:00
|
|
|
|
HARDWARE_CHAR_OUT((char)(0x80 + (utf_hi_char << 6) + d)) ;
|
2015-03-11 04:55:16 -05:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
else {
|
2015-10-13 05:51:34 -05:00
|
|
|
|
HARDWARE_CHAR_OUT('?');
|
2015-03-11 04:55:16 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2017-04-21 21:42:27 -05:00
|
|
|
|
HARDWARE_CHAR_OUT((char)c);
|
2015-03-11 04:55:16 -05:00
|
|
|
|
}
|
2016-07-10 20:59:04 -05:00
|
|
|
|
seen_ce = false;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#elif ENABLED(MAPPER_CECF)
|
|
|
|
|
|
2016-11-24 00:54:21 -06:00
|
|
|
|
char charset_mapper(const char c) {
|
2016-07-10 20:59:04 -05:00
|
|
|
|
static uint8_t utf_hi_char; // UTF-8 high part
|
|
|
|
|
static bool seen_ce = false;
|
|
|
|
|
uint8_t d = c;
|
2017-04-21 21:42:27 -05:00
|
|
|
|
if (d >= 0x80) { // UTF-8 handling
|
|
|
|
|
if (d >= 0xC0 && !seen_ce) {
|
|
|
|
|
utf_hi_char = d - 0xCE;
|
2016-07-10 20:59:04 -05:00
|
|
|
|
seen_ce = true;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
else if (seen_ce) {
|
2017-04-21 21:42:27 -05:00
|
|
|
|
d &= 0x3F;
|
2016-07-10 20:59:04 -05:00
|
|
|
|
#ifndef MAPPER_ONE_TO_ONE
|
|
|
|
|
HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
|
|
|
|
|
#else
|
|
|
|
|
HARDWARE_CHAR_OUT((char)(0x80 + (utf_hi_char << 6) + d)) ;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
HARDWARE_CHAR_OUT('?');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
HARDWARE_CHAR_OUT((char) c );
|
|
|
|
|
}
|
|
|
|
|
seen_ce = false;
|
2015-03-11 04:55:16 -05:00
|
|
|
|
return 1;
|
|
|
|
|
}
|
2015-10-13 05:51:34 -05:00
|
|
|
|
|
2015-07-31 00:03:15 -05:00
|
|
|
|
#elif ENABLED(MAPPER_D0D1_MOD)
|
2015-10-13 05:51:34 -05:00
|
|
|
|
|
2016-11-24 00:54:21 -06:00
|
|
|
|
char charset_mapper(const char c) {
|
2015-03-11 04:55:16 -05:00
|
|
|
|
// it is a Russian alphabet translation
|
2017-04-21 21:42:27 -05:00
|
|
|
|
// except 0401 --> 0xA2 = Ё, 0451 --> 0xB5 = ё
|
2015-10-13 05:55:16 -05:00
|
|
|
|
static uint8_t utf_hi_char; // UTF-8 high part
|
|
|
|
|
static bool seen_d5 = false;
|
2015-03-11 04:55:16 -05:00
|
|
|
|
uint8_t d = c;
|
2015-10-13 05:51:34 -05:00
|
|
|
|
if (d >= 0x80) { // UTF-8 handling
|
2017-04-21 21:42:27 -05:00
|
|
|
|
if (d >= 0xD0 && !seen_d5) {
|
|
|
|
|
utf_hi_char = d - 0xD0;
|
2015-03-11 04:55:16 -05:00
|
|
|
|
seen_d5 = true;
|
|
|
|
|
return 0;
|
2015-10-13 05:51:34 -05:00
|
|
|
|
}
|
|
|
|
|
else if (seen_d5) {
|
2017-04-21 21:42:27 -05:00
|
|
|
|
d &= 0x3F;
|
2015-10-13 05:51:34 -05:00
|
|
|
|
if (!utf_hi_char && d == 1) {
|
2017-04-21 21:42:27 -05:00
|
|
|
|
HARDWARE_CHAR_OUT((char) 0xA2); // Ё
|
2015-10-13 05:51:34 -05:00
|
|
|
|
}
|
|
|
|
|
else if (utf_hi_char == 1 && d == 0x11) {
|
2017-04-21 21:42:27 -05:00
|
|
|
|
HARDWARE_CHAR_OUT((char)0xB5); // ё
|
2015-03-11 04:55:16 -05:00
|
|
|
|
}
|
|
|
|
|
else {
|
2015-10-13 05:51:34 -05:00
|
|
|
|
HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x10));
|
2015-03-11 04:55:16 -05:00
|
|
|
|
}
|
2015-10-13 05:51:34 -05:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
HARDWARE_CHAR_OUT('?');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
2015-03-17 05:23:44 -05:00
|
|
|
|
HARDWARE_CHAR_OUT((char) c );
|
2015-03-11 04:55:16 -05:00
|
|
|
|
}
|
|
|
|
|
seen_d5 = false;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2015-10-13 05:51:34 -05:00
|
|
|
|
|
2015-07-31 00:03:15 -05:00
|
|
|
|
#elif ENABLED(MAPPER_D0D1)
|
2015-10-13 05:55:16 -05:00
|
|
|
|
|
2016-11-24 00:54:21 -06:00
|
|
|
|
char charset_mapper(const char c) {
|
2015-10-13 05:55:16 -05:00
|
|
|
|
static uint8_t utf_hi_char; // UTF-8 high part
|
|
|
|
|
static bool seen_d5 = false;
|
2015-03-11 04:55:16 -05:00
|
|
|
|
uint8_t d = c;
|
2015-10-13 05:51:34 -05:00
|
|
|
|
if (d >= 0x80u) { // UTF-8 handling
|
2017-04-21 21:42:27 -05:00
|
|
|
|
if (d >= 0xD0u && !seen_d5) {
|
|
|
|
|
utf_hi_char = d - 0xD0u;
|
2015-03-11 04:55:16 -05:00
|
|
|
|
seen_d5 = true;
|
|
|
|
|
return 0;
|
2015-10-13 05:51:34 -05:00
|
|
|
|
}
|
|
|
|
|
else if (seen_d5) {
|
2017-04-21 21:42:27 -05:00
|
|
|
|
d &= 0x3Fu;
|
2015-03-11 04:55:16 -05:00
|
|
|
|
#ifndef MAPPER_ONE_TO_ONE
|
2015-10-13 05:51:34 -05:00
|
|
|
|
HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
|
2015-03-11 04:55:16 -05:00
|
|
|
|
#else
|
2017-04-21 21:42:27 -05:00
|
|
|
|
HARDWARE_CHAR_OUT((char)(0xA0u + (utf_hi_char << 6) + d)) ;
|
2015-03-11 04:55:16 -05:00
|
|
|
|
#endif
|
2015-10-13 05:51:34 -05:00
|
|
|
|
}
|
|
|
|
|
else {
|
2015-03-17 05:23:44 -05:00
|
|
|
|
HARDWARE_CHAR_OUT('?');
|
2015-03-11 04:55:16 -05:00
|
|
|
|
}
|
2015-10-13 05:51:34 -05:00
|
|
|
|
}
|
|
|
|
|
else {
|
2015-03-17 05:23:44 -05:00
|
|
|
|
HARDWARE_CHAR_OUT((char) c );
|
2015-03-11 04:55:16 -05:00
|
|
|
|
}
|
|
|
|
|
seen_d5 = false;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2015-10-13 05:51:34 -05:00
|
|
|
|
|
2015-07-31 00:03:15 -05:00
|
|
|
|
#elif ENABLED(MAPPER_E382E383)
|
2015-10-13 05:55:16 -05:00
|
|
|
|
|
2016-11-24 00:54:21 -06:00
|
|
|
|
char charset_mapper(const char c) {
|
2015-10-13 05:55:16 -05:00
|
|
|
|
static uint8_t utf_hi_char; // UTF-8 high part
|
2017-04-21 21:42:27 -05:00
|
|
|
|
static bool seen_e3 = false,
|
|
|
|
|
seen_82_83 = false;
|
2015-10-03 01:08:58 -05:00
|
|
|
|
uint8_t d = c;
|
2015-10-13 05:51:34 -05:00
|
|
|
|
if (d >= 0x80) { // UTF-8 handling
|
2017-04-21 21:42:27 -05:00
|
|
|
|
if (d == 0xE3 && !seen_e3) {
|
2015-03-11 04:55:16 -05:00
|
|
|
|
seen_e3 = true;
|
2017-04-21 21:42:27 -05:00
|
|
|
|
return 0; // eat 0xE3
|
2015-10-13 05:51:34 -05:00
|
|
|
|
}
|
|
|
|
|
else if (d >= 0x82 && seen_e3 && !seen_82_83) {
|
2015-03-11 04:55:16 -05:00
|
|
|
|
utf_hi_char = d - 0x82;
|
|
|
|
|
seen_82_83 = true;
|
|
|
|
|
return 0;
|
2015-10-13 05:51:34 -05:00
|
|
|
|
}
|
|
|
|
|
else if (seen_e3 && seen_82_83) {
|
2017-04-21 21:42:27 -05:00
|
|
|
|
d &= 0x3F;
|
2015-03-11 04:55:16 -05:00
|
|
|
|
#ifndef MAPPER_ONE_TO_ONE
|
2015-10-13 05:51:34 -05:00
|
|
|
|
HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
|
2015-03-11 04:55:16 -05:00
|
|
|
|
#else
|
2015-10-13 05:51:34 -05:00
|
|
|
|
HARDWARE_CHAR_OUT((char)(0x80 + (utf_hi_char << 6) + d)) ;
|
2015-03-11 04:55:16 -05:00
|
|
|
|
#endif
|
2015-10-13 05:51:34 -05:00
|
|
|
|
}
|
|
|
|
|
else {
|
2015-03-17 05:23:44 -05:00
|
|
|
|
HARDWARE_CHAR_OUT((char) '?' );
|
2015-03-11 04:55:16 -05:00
|
|
|
|
}
|
2015-10-13 05:51:34 -05:00
|
|
|
|
}
|
|
|
|
|
else {
|
2015-03-17 05:23:44 -05:00
|
|
|
|
HARDWARE_CHAR_OUT((char) c );
|
2015-03-11 04:55:16 -05:00
|
|
|
|
}
|
|
|
|
|
seen_e3 = false;
|
|
|
|
|
seen_82_83 = false;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2015-10-13 05:51:34 -05:00
|
|
|
|
|
2017-04-21 09:05:29 -05:00
|
|
|
|
#elif ENABLED(MAPPER_C3C4C5_PL)
|
|
|
|
|
|
|
|
|
|
//Ą c4 84 = 80
|
|
|
|
|
//ą c4 85 = 81
|
|
|
|
|
//Ć c4 86 = 82
|
|
|
|
|
//ć c4 87 = 83
|
|
|
|
|
//Ę c4 98 = 84
|
|
|
|
|
//ę c4 99 = 85
|
|
|
|
|
//Ł c5 81 = 86
|
|
|
|
|
//ł c5 82 = 87
|
|
|
|
|
//Ń c5 83 = 88
|
|
|
|
|
//ń c5 84 = 89
|
|
|
|
|
//Ó c3 93 = 8a
|
|
|
|
|
//ó c3 b3 = 8b
|
|
|
|
|
//Ś c5 9a = 8c
|
|
|
|
|
//ś c5 9b = 8d
|
|
|
|
|
//Ź c5 b9 = 8e
|
|
|
|
|
//ź c5 ba = 8f
|
|
|
|
|
//Ż c5 bb = 90
|
|
|
|
|
//ż c5 bc = 91
|
|
|
|
|
|
|
|
|
|
char charset_mapper(const char c) {
|
|
|
|
|
static uint8_t utf_hi_char; // UTF-8 high part
|
|
|
|
|
static bool seen_c3 = false,
|
|
|
|
|
seen_c4 = false,
|
|
|
|
|
seen_c5 = false;
|
|
|
|
|
uint8_t d = c;
|
2017-05-21 05:58:03 -05:00
|
|
|
|
if (d >= 0x80u) { // UTF-8 handling
|
|
|
|
|
if (d == 0xC4u) { seen_c4 = true; return 0; }
|
|
|
|
|
else if (d == 0xC5u) { seen_c5 = true; return 0; }
|
|
|
|
|
else if (d == 0xC3u) { seen_c3 = true; return 0; }
|
2017-04-21 09:05:29 -05:00
|
|
|
|
else if (seen_c4) {
|
|
|
|
|
switch(d) {
|
|
|
|
|
case 0x84u ... 0x87u: d -= 4; break; //Ą - ć
|
|
|
|
|
case 0x98u ... 0x99u: d -= 20; break; //Ę i ę
|
|
|
|
|
default: d = '?';
|
|
|
|
|
}
|
|
|
|
|
HARDWARE_CHAR_OUT((char)d) ;
|
|
|
|
|
}
|
|
|
|
|
else if (seen_c5) {
|
|
|
|
|
switch(d) {
|
|
|
|
|
case 0x81u ... 0x84u: d += 5; break; //Ł - ń
|
|
|
|
|
case 0x9Au ... 0x9Bu: d -= 0x0Eu; break; //Ś i ś
|
|
|
|
|
case 0xB9u ... 0xBCu: d -= 0x2Bu; break; //Ź - ż
|
|
|
|
|
default: d = '?';
|
|
|
|
|
}
|
|
|
|
|
HARDWARE_CHAR_OUT((char)d) ;
|
|
|
|
|
}
|
|
|
|
|
else if (seen_c3) {
|
|
|
|
|
switch(d) {
|
|
|
|
|
case 0x93u: d = 0x8Au; break; //Ó
|
|
|
|
|
case 0xB3u: d = 0x8Bu; break; //ó
|
|
|
|
|
d = '?';
|
|
|
|
|
}
|
|
|
|
|
HARDWARE_CHAR_OUT((char)d) ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
HARDWARE_CHAR_OUT((char) c );
|
|
|
|
|
}
|
|
|
|
|
seen_c3 = seen_c4 = seen_c5 = false;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-11 04:55:16 -05:00
|
|
|
|
#else
|
2015-10-13 05:51:34 -05:00
|
|
|
|
|
2016-07-12 12:42:42 -05:00
|
|
|
|
#define MAPPER_NON
|
|
|
|
|
|
2016-11-24 00:54:21 -06:00
|
|
|
|
char charset_mapper(const char c) {
|
2016-07-12 12:42:42 -05:00
|
|
|
|
HARDWARE_CHAR_OUT( c );
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
2015-10-13 05:51:34 -05:00
|
|
|
|
|
2016-07-12 12:42:42 -05:00
|
|
|
|
#endif // code mappers
|
2015-03-11 04:55:16 -05:00
|
|
|
|
|
|
|
|
|
#endif // UTF_MAPPER_H
|