My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #ifndef UTF_MAPPER_H
  23. #define UTF_MAPPER_H
  24. #include "language.h"
  25. #if ENABLED(DOGLCD)
  26. #define HARDWARE_CHAR_OUT u8g.print
  27. #else
  28. #define HARDWARE_CHAR_OUT lcd.write
  29. #endif
  30. #if DISABLED(SIMULATE_ROMFONT) && ENABLED(DOGLCD)
  31. #if ENABLED(DISPLAY_CHARSET_ISO10646_1) \
  32. || ENABLED(DISPLAY_CHARSET_ISO10646_5) \
  33. || ENABLED(DISPLAY_CHARSET_ISO10646_KANA) \
  34. || ENABLED(DISPLAY_CHARSET_ISO10646_GREEK) \
  35. || ENABLED(DISPLAY_CHARSET_ISO10646_TR)
  36. #define MAPPER_ONE_TO_ONE
  37. #endif
  38. #else // SIMULATE_ROMFONT
  39. #if DISPLAY_CHARSET_HD44780 == JAPANESE
  40. #if ENABLED(MAPPER_C2C3)
  41. const PROGMEM uint8_t utf_recode[] =
  42. { // 0 1 2 3 4 5 6 7 8 9 a b c d e f This is fair for symbols
  43. 0x20,0x3F,0xEC,0xED,0x3F,0x5C,0x7C,0x3F,0x22,0x63,0x61,0x7F,0x3F,0x3F,0x52,0xB0, // c2a
  44. //' ' ¢ £ ­ l " c a « R
  45. 0xDF,0x3F,0x32,0x33,0x27,0xE4,0xF1,0xA5,0x2C,0x31,0xDF,0x7E,0x3F,0x3F,0x3F,0x3F, // c2b but relatively bad for letters.
  46. // ° 2 3 ` N p . , 1 ° »
  47. 0x3F,0x3F,0x3F,0x3F,0xE1,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F, // c38
  48. // ä
  49. 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0xEF,0x78,0x3F,0x3F,0x3F,0x3F,0xF5,0x3F,0x3F,0xE2, // c39 missing characters display as '?'
  50. // ö x ü ß
  51. 0x3F,0x3F,0x3F,0x3F,0xE1,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F, // c3a
  52. // ä
  53. 0x3F,0xEE,0x3F,0x3F,0x3F,0x3F,0xEF,0xFD,0x3F,0x3F,0x3F,0x3F,0xF5,0x3F,0x3F,0x3F // c3b
  54. // n ö ÷ ü
  55. };
  56. #elif ENABLED(MAPPER_E382E383)
  57. const PROGMEM uint8_t utf_recode[] =
  58. { // 0 1 2 3 4 5 6 7 8 9 a b c d e f
  59. 0x3D,0xB1,0xB1,0xA8,0xB2,0xA9,0xB3,0xAA,0xB4,0xAB,0xB5,0xB6,0xB6,0xB7,0xB7,0xB8, // e382a Please test and correct
  60. // = ア ア ィ イ ゥ ウ ェ エ ォ オ ガ ガ キ キ ク
  61. 0xB8,0xB9,0xB9,0xBA,0xBA,0xBB,0xBB,0xBC,0xBC,0xBD,0xBD,0xBE,0xBE,0xBF,0xBF,0xC0, // e382b
  62. // ク ケ ケ コ コ サ サ シ シ ス ス セ セ ソ ソ タ
  63. 0xC0,0xC1,0xC1,0xC2,0xC2,0xC2,0xC3,0xC3,0xC4,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA, // e3838
  64. // タ チ チ ッ ッ ッ テ テ ト ト ナ ニ ヌ ネ ノ ハ
  65. 0xCA,0xCA,0xCB,0xCB,0xCB,0xCC,0xCC,0xCC,0xCD,0xCD,0xCD,0xCE,0xCE,0xCE,0xCF,0xD0, // e3839
  66. // ハ ハ ヒ ヒ ヒ フ フ フ ヘ ヘ ヘ ホ ホ ホ マ ミ
  67. 0xD1,0xD2,0xD3,0xD4,0xD4,0xD5,0xD5,0xAE,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDC, // e383a
  68. // ム メ モ ャ ャ ユ ユ ョ ヨ ラ リ ル レ ロ ワ ワ
  69. 0xEC,0xA7,0xA6,0xDD,0xCC,0x3F,0x3F,0x3F,0x3F,0x3F,0xA6,0xA5,0xB0,0xA4,0xA4,0x3F // e383b
  70. // ヰ ヱ ヲ ン フ ? ? ? ? ? ヲ ・ ー ヽ ヽ ?
  71. };
  72. #elif ENABLED(MAPPER_D0D1)
  73. #error "Cyrillic on a JAPANESE display makes no sense. There are no matching symbols."
  74. #endif
  75. #elif DISPLAY_CHARSET_HD44780 == WESTERN
  76. #if ENABLED(MAPPER_C2C3)
  77. const PROGMEM uint8_t utf_recode[] =
  78. { // 0 1 2 3 4 5 6 7 8 9 a b c d e f This is relative complete.
  79. 0x20,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0x22,0xA9,0xAA,0xAB,0x3F,0x3F,0xAE,0x3F, // c2a ¡¢£¤¥¦§¨©ª«¬­®¯
  80. //' ' ¡ ¢ £ ¤ ¥ ¦ § " © ª « ? ? ® ?
  81. 0xB0,0xB1,0xB2,0xB3,0x27,0xB5,0xB6,0xB7,0x2C,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, // c2b °±²³´µ¶·¸¹º»¼½¾¿
  82. // ° ± ³ ² ? µ ¶ · , ¹ º » ¼ ½ ¾ ¿
  83. 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, // c38 ÀÁÃÄÅÆÇÈÉÊËÌÍÎÏ
  84. // À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï
  85. 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, // c39 ÐÑÓÔÕÖ×ØÙÚÛÜÝÞß
  86. // Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß
  87. 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, // c3a àáãäåæçèéêëìíîï
  88. // à á â ã ä å æ ç è é ê ë ì í î ï
  89. 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF // c3b ðñóôõö÷øùúûüýþÿ
  90. // ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ
  91. };
  92. #elif ENABLED(MAPPER_D0D1)
  93. #define MAPPER_D0D1_MOD
  94. const PROGMEM uint8_t utf_recode[] =
  95. {//0 1 2 3 4 5 6 7 8 9 a b c d e f
  96. 0x41,0x80,0x42,0x92,0x81,0x45,0x82,0x83,0x84,0x85,0x4B,0x86,0x4D,0x48,0x4F,0x87, // d0a
  97. // A Б B Г Д E Ж З И Й K Л M H O П
  98. 0x50,0x43,0x54,0x88,0xD8,0x58,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x62,0x8F,0xAC,0xAD, // d0b
  99. // P C T У Ф X Ч ч Ш Щ Ъ Ы b Э Ю Я
  100. 0x61,0x36,0x42,0x92,0x81,0x65,0x82,0xB3,0x84,0x85,0x6B,0x86,0x4D,0x48,0x6F,0x87, // d18
  101. // a 6 B Г Д e Ж ³ И Й k Л M H o П
  102. 0x70,0x63,0x54,0x79,0xD8,0x78,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x62,0x8F,0xAC,0xAD // d19
  103. // p c T y Ф x Ч ч Ш Щ Ъ Ы b Э Ю Я
  104. };
  105. #elif ENABLED(MAPPER_E382E383)
  106. #error "Katakana on a WESTERN display makes no sense. There are no matching symbols."
  107. #endif
  108. #elif DISPLAY_CHARSET_HD44780 == CYRILLIC
  109. #if ENABLED(MAPPER_D0D1)
  110. #define MAPPER_D0D1_MOD
  111. // it is a Russian alphabet translation
  112. // except 0401 --> 0xA2 = Ё, 0451 --> 0xB5 = ё
  113. const PROGMEM uint8_t utf_recode[] =
  114. { 0x41,0xA0,0x42,0xA1,0xE0,0x45,0xA3,0xA4, // unicode U+0400 to U+047f
  115. // A Б->Ё B Г Д E Ж З // 0 Ѐ Ё Ђ Ѓ Є Ѕ І Ї
  116. 0xA5,0xA6,0x4B,0xA7,0x4D,0x48,0x4F,0xA8, // Ј Љ Њ Ћ Ќ Ѝ Ў Џ
  117. // И Й K Л M H O П // 1 А Б В Г Д Е Ж З
  118. 0x50,0x43,0x54,0xA9,0xAA,0x58,0xE1,0xAB, // И Й К Л М Н О П
  119. // P C T У Ф X Ч ч // 2 Р С Т У Ф Х Г Ч
  120. 0xAC,0xE2,0xAD,0xAE,0x62,0xAF,0xB0,0xB1, // Ш Щ Ъ Ы Ь Э Ю Я
  121. // Ш Щ Ъ Ы b Э Ю Я // 3 а б в г д е ж з
  122. 0x61,0xB2,0xB3,0xB4,0xE3,0x65,0xB6,0xB7, // и й к л м н о п
  123. // a б->ё в г д e ж з // 4 р с т у ф х ц ч
  124. 0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0x6F,0xBE, // ш щ ъ ы ь э ю я
  125. // и й к л м н o п // 5 ѐ ё ђ ѓ є ѕ і ї
  126. 0x70,0x63,0xBF,0x79,0xE4,0x78,0xE5,0xC0, // ј љ њ ћ ќ ѝ ў џ
  127. // p c т y ф x ц ч // 6 Ѡ ѡ Ѣ ѣ Ѥ ѥ Ѧ ѧ
  128. 0xC1,0xE6,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7 // Ѫ ѩ Ѫ ѫ Ѭ ѭ Ѯ ѯ
  129. // ш щ ъ ы ь э ю я // 7 Ѱ ѱ Ѳ ѳ Ѵ ѵ Ѷ ѷ
  130. }; // ѻ ѹ Ѻ ѻ Ѽ ѽ Ѿ ѿ
  131. #elif ENABLED(MAPPER_C2C3)
  132. #error "Western languages on a CYRILLIC display makes no sense. There are no matching symbols."
  133. #elif ENABLED(MAPPER_E382E383)
  134. #error "Katakana on a CYRILLIC display makes no sense. There are no matching symbols."
  135. #endif
  136. #else
  137. #error "Something went wrong in the setting of DISPLAY_CHARSET_HD44780"
  138. #endif // DISPLAY_CHARSET_HD44780
  139. #endif // SIMULATE_ROMFONT
  140. #if ENABLED(MAPPER_C2C3)
  141. char charset_mapper(const char c) {
  142. static uint8_t utf_hi_char; // UTF-8 high part
  143. static bool seen_c2 = false;
  144. uint8_t d = c;
  145. if ( d >= 0x80u ) { // UTF-8 handling
  146. if ( (d >= 0xC0u) && (!seen_c2) ) {
  147. utf_hi_char = d - 0xC2u;
  148. seen_c2 = true;
  149. return 0;
  150. }
  151. else if (seen_c2) {
  152. d &= 0x3Fu;
  153. #ifndef MAPPER_ONE_TO_ONE
  154. HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
  155. #else
  156. HARDWARE_CHAR_OUT((char)(0x80u + (utf_hi_char << 6) + d)) ;
  157. #endif
  158. }
  159. else {
  160. HARDWARE_CHAR_OUT('?');
  161. }
  162. }
  163. else {
  164. HARDWARE_CHAR_OUT((char) c );
  165. }
  166. seen_c2 = false;
  167. return 1;
  168. }
  169. #elif ENABLED(MAPPER_C2C3_TR)
  170. // the C2C3-mapper extended for the 6 altered symbols from C4 and C5 range.
  171. char charset_mapper(const char c) {
  172. static uint8_t utf_hi_char; // UTF-8 high part
  173. static bool seen_c2 = false,
  174. seen_c4 = false,
  175. seen_c5 = false;
  176. uint8_t d = c;
  177. if ( d >= 0x80u ) { // UTF-8 handling
  178. if ( d == 0xC4u ) {seen_c4 = true; return 0;}
  179. else if ( d == 0xC5u ) {seen_c5 = true; return 0;}
  180. else if ( (d >= 0xC0u) && (!seen_c2) ) {
  181. utf_hi_char = d - 0xC2u;
  182. seen_c2 = true;
  183. return 0;
  184. }
  185. else if (seen_c4) {
  186. switch(d) {
  187. case 0x9Eu: d = 0xD0u; break;
  188. case 0x9Fu: d = 0xF0u; break;
  189. case 0xB0u: d = 0xDDu; break;
  190. case 0xB1u: d = 0xFDu; break;
  191. default: d = '?';
  192. }
  193. HARDWARE_CHAR_OUT((char)d) ;
  194. }
  195. else if (seen_c5) {
  196. switch(d) {
  197. case 0x9Eu: d = 0xDEu; break;
  198. case 0x9Fu: d = 0xFEu; break;
  199. default: d = '?';
  200. }
  201. HARDWARE_CHAR_OUT((char)d) ;
  202. }
  203. else if (seen_c2) {
  204. d &= 0x3Fu;
  205. #ifndef MAPPER_ONE_TO_ONE
  206. HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
  207. #else
  208. HARDWARE_CHAR_OUT((char)(0x80u + (utf_hi_char << 6) + d)) ;
  209. #endif
  210. }
  211. else {
  212. HARDWARE_CHAR_OUT('?');
  213. }
  214. }
  215. else {
  216. HARDWARE_CHAR_OUT((char) c );
  217. }
  218. seen_c2 = seen_c4 = seen_c5 = false;
  219. return 1;
  220. }
  221. #elif ENABLED(MAPPER_CECF)
  222. char charset_mapper(const char c) {
  223. static uint8_t utf_hi_char; // UTF-8 high part
  224. static bool seen_ce = false;
  225. uint8_t d = c;
  226. if ( d >= 0x80 ) { // UTF-8 handling
  227. if ( (d >= 0xC0) && (!seen_ce) ) {
  228. utf_hi_char = d - 0xCE;
  229. seen_ce = true;
  230. return 0;
  231. }
  232. else if (seen_ce) {
  233. d &= 0x3F;
  234. #ifndef MAPPER_ONE_TO_ONE
  235. HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
  236. #else
  237. HARDWARE_CHAR_OUT((char)(0x80 + (utf_hi_char << 6) + d)) ;
  238. #endif
  239. }
  240. else {
  241. HARDWARE_CHAR_OUT('?');
  242. }
  243. }
  244. else {
  245. HARDWARE_CHAR_OUT((char)c);
  246. }
  247. seen_ce = false;
  248. return 1;
  249. }
  250. #elif ENABLED(MAPPER_CECF)
  251. char charset_mapper(const char c) {
  252. static uint8_t utf_hi_char; // UTF-8 high part
  253. static bool seen_ce = false;
  254. uint8_t d = c;
  255. if (d >= 0x80) { // UTF-8 handling
  256. if (d >= 0xC0 && !seen_ce) {
  257. utf_hi_char = d - 0xCE;
  258. seen_ce = true;
  259. return 0;
  260. }
  261. else if (seen_ce) {
  262. d &= 0x3F;
  263. #ifndef MAPPER_ONE_TO_ONE
  264. HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
  265. #else
  266. HARDWARE_CHAR_OUT((char)(0x80 + (utf_hi_char << 6) + d)) ;
  267. #endif
  268. }
  269. else {
  270. HARDWARE_CHAR_OUT('?');
  271. }
  272. }
  273. else {
  274. HARDWARE_CHAR_OUT((char) c );
  275. }
  276. seen_ce = false;
  277. return 1;
  278. }
  279. #elif ENABLED(MAPPER_D0D1_MOD)
  280. char charset_mapper(const char c) {
  281. // it is a Russian alphabet translation
  282. // except 0401 --> 0xA2 = Ё, 0451 --> 0xB5 = ё
  283. static uint8_t utf_hi_char; // UTF-8 high part
  284. static bool seen_d5 = false;
  285. uint8_t d = c;
  286. if (d >= 0x80) { // UTF-8 handling
  287. if (d >= 0xD0 && !seen_d5) {
  288. utf_hi_char = d - 0xD0;
  289. seen_d5 = true;
  290. return 0;
  291. }
  292. else if (seen_d5) {
  293. d &= 0x3F;
  294. if (!utf_hi_char && d == 1) {
  295. HARDWARE_CHAR_OUT((char) 0xA2); // Ё
  296. }
  297. else if (utf_hi_char == 1 && d == 0x11) {
  298. HARDWARE_CHAR_OUT((char)0xB5); // ё
  299. }
  300. else {
  301. HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x10));
  302. }
  303. }
  304. else {
  305. HARDWARE_CHAR_OUT('?');
  306. }
  307. }
  308. else {
  309. HARDWARE_CHAR_OUT((char) c );
  310. }
  311. seen_d5 = false;
  312. return 1;
  313. }
  314. #elif ENABLED(MAPPER_D0D1)
  315. char charset_mapper(const char c) {
  316. static uint8_t utf_hi_char; // UTF-8 high part
  317. static bool seen_d5 = false;
  318. uint8_t d = c;
  319. if (d >= 0x80u) { // UTF-8 handling
  320. if (d >= 0xD0u && !seen_d5) {
  321. utf_hi_char = d - 0xD0u;
  322. seen_d5 = true;
  323. return 0;
  324. }
  325. else if (seen_d5) {
  326. d &= 0x3Fu;
  327. #ifndef MAPPER_ONE_TO_ONE
  328. HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
  329. #else
  330. HARDWARE_CHAR_OUT((char)(0xA0u + (utf_hi_char << 6) + d)) ;
  331. #endif
  332. }
  333. else {
  334. HARDWARE_CHAR_OUT('?');
  335. }
  336. }
  337. else {
  338. HARDWARE_CHAR_OUT((char) c );
  339. }
  340. seen_d5 = false;
  341. return 1;
  342. }
  343. #elif ENABLED(MAPPER_E382E383)
  344. char charset_mapper(const char c) {
  345. static uint8_t utf_hi_char; // UTF-8 high part
  346. static bool seen_e3 = false,
  347. seen_82_83 = false;
  348. uint8_t d = c;
  349. if (d >= 0x80) { // UTF-8 handling
  350. if (d == 0xE3 && !seen_e3) {
  351. seen_e3 = true;
  352. return 0; // eat 0xE3
  353. }
  354. else if (d >= 0x82 && seen_e3 && !seen_82_83) {
  355. utf_hi_char = d - 0x82;
  356. seen_82_83 = true;
  357. return 0;
  358. }
  359. else if (seen_e3 && seen_82_83) {
  360. d &= 0x3F;
  361. #ifndef MAPPER_ONE_TO_ONE
  362. HARDWARE_CHAR_OUT((char)pgm_read_byte_near(utf_recode + d + (utf_hi_char << 6) - 0x20));
  363. #else
  364. HARDWARE_CHAR_OUT((char)(0x80 + (utf_hi_char << 6) + d)) ;
  365. #endif
  366. }
  367. else {
  368. HARDWARE_CHAR_OUT((char) '?' );
  369. }
  370. }
  371. else {
  372. HARDWARE_CHAR_OUT((char) c );
  373. }
  374. seen_e3 = false;
  375. seen_82_83 = false;
  376. return 1;
  377. }
  378. #elif ENABLED(MAPPER_C3C4C5_PL)
  379. //Ą c4 84 = 80
  380. //ą c4 85 = 81
  381. //Ć c4 86 = 82
  382. //ć c4 87 = 83
  383. //Ę c4 98 = 84
  384. //ę c4 99 = 85
  385. //Ł c5 81 = 86
  386. //ł c5 82 = 87
  387. //Ń c5 83 = 88
  388. //ń c5 84 = 89
  389. //Ó c3 93 = 8a
  390. //ó c3 b3 = 8b
  391. //Ś c5 9a = 8c
  392. //ś c5 9b = 8d
  393. //Ź c5 b9 = 8e
  394. //ź c5 ba = 8f
  395. //Ż c5 bb = 90
  396. //ż c5 bc = 91
  397. char charset_mapper(const char c) {
  398. static uint8_t utf_hi_char; // UTF-8 high part
  399. static bool seen_c3 = false,
  400. seen_c4 = false,
  401. seen_c5 = false;
  402. uint8_t d = c;
  403. if ( d >= 0x80u ) { // UTF-8 handling
  404. if ( d == 0xC4u ) {seen_c4 = true; return 0;}
  405. else if ( d == 0xC5u ) {seen_c5 = true; return 0;}
  406. else if ( d == 0xC3u ) {seen_c3 = true; return 0;}
  407. else if (seen_c4) {
  408. switch(d) {
  409. case 0x84u ... 0x87u: d -= 4; break; //Ą - ć
  410. case 0x98u ... 0x99u: d -= 20; break; //Ę i ę
  411. default: d = '?';
  412. }
  413. HARDWARE_CHAR_OUT((char)d) ;
  414. }
  415. else if (seen_c5) {
  416. switch(d) {
  417. case 0x81u ... 0x84u: d += 5; break; //Ł - ń
  418. case 0x9Au ... 0x9Bu: d -= 0x0Eu; break; //Ś i ś
  419. case 0xB9u ... 0xBCu: d -= 0x2Bu; break; //Ź - ż
  420. default: d = '?';
  421. }
  422. HARDWARE_CHAR_OUT((char)d) ;
  423. }
  424. else if (seen_c3) {
  425. switch(d) {
  426. case 0x93u: d = 0x8Au; break; //Ó
  427. case 0xB3u: d = 0x8Bu; break; //ó
  428. d = '?';
  429. }
  430. HARDWARE_CHAR_OUT((char)d) ;
  431. }
  432. }
  433. else {
  434. HARDWARE_CHAR_OUT((char) c );
  435. }
  436. seen_c3 = seen_c4 = seen_c5 = false;
  437. return 1;
  438. }
  439. #else
  440. #define MAPPER_NON
  441. char charset_mapper(const char c) {
  442. HARDWARE_CHAR_OUT( c );
  443. return 1;
  444. }
  445. #endif // code mappers
  446. #endif // UTF_MAPPER_H