123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- #ifndef UTF_MAPPER_H
- #define UTF_MAPPER_H
-
- #include "language.h"
-
- #ifdef DOGLCD
- #define HARDWARE_CHAR_OUT u8g.print
- #else
- #define HARDWARE_CHAR_OUT lcd.write
- #endif
-
- #if !(defined( SIMULATE_ROMFONT )) && defined( DOGLCD )
- #if defined( DISPLAY_CHARSET_ISO10646_1 )
- #define MAPPER_ONE_TO_ONE
- #elif defined( DISPLAY_CHARSET_ISO10646_5 )
- #define MAPPER_ONE_TO_ONE
- #elif defined( DISPLAY_CHARSET_ISO10646_KANA )
- #define MAPPER_ONE_TO_ONE
- #endif
- #else
- #if defined( DISPLAY_CHARSET_HD44780_JAPAN )
- #if defined( MAPPER_C2C3 )
- const PROGMEM uint8_t utf_recode[] =
- {
- 0x20,0x3f,0xec,0xed,0x3f,0x5c,0x7c,0x3f,0x22,0x63,0x61,0x7f,0x3f,0x3f,0x52,0xb0,
-
- 0xdf,0x3f,0x32,0x33,0x27,0xe4,0xf1,0xa5,0x2c,0x31,0xdf,0x7e,0x3f,0x3f,0x3f,0x3f,
-
- 0x3f,0x3f,0x3f,0x3f,0xe1,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
-
- 0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0xef,0x78,0x3f,0x3f,0x3f,0x3f,0xf5,0x3f,0x3f,0xe2,
-
- 0x3f,0x3f,0x3f,0x3f,0xe1,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,0x3f,
-
- 0x3f,0xee,0x3f,0x3f,0x3f,0x3f,0xef,0xfd,0x3f,0x3f,0x3f,0x3f,0xf5,0x3f,0x3f,0x3f
-
- };
- #elif defined( MAPPER_E382E383 )
- const PROGMEM uint8_t utf_recode[] =
- {
- 0x3d,0xb1,0xb1,0xa8,0xb2,0xa9,0xb3,0xaa,0xb4,0xab,0xb5,0xb6,0xb6,0xb7,0xb7,0xb8,
-
- 0xb8,0xb9,0xb9,0xba,0xba,0xbb,0xbb,0xbc,0xbc,0xbd,0xbd,0xbe,0xbe,0xbf,0xbf,0xc0,
-
- 0xc0,0xc1,0xc1,0xc2,0xc2,0xc2,0xc3,0xc3,0xc4,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,
-
- 0xca,0xca,0xcb,0xcb,0xcb,0xcc,0xcc,0xcc,0xcd,0xcd,0xcd,0xce,0xce,0xce,0xcf,0xd0,
-
- 0xd1,0xd2,0xd3,0xd4,0xd4,0xd5,0xd5,0xae,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdc,
-
- 0xec,0xa7,0xa6,0xdd,0xcc,0x3f,0x3f,0x3f,0x3f,0x3f,0xa6,0xa5,0xb0,0xa4,0xa4,0x3f
-
- };
- #elif defined( MAPPER_D0D1 )
- #error( "Cyrillic on a japanese dsplay makes no sense. There are no matching symbols.");
- #endif
-
- #elif defined( DISPLAY_CHARSET_HD44780_WESTERN )
- #if defined( MAPPER_C2C3 )
- :
- const PROGMEM uint8_t utf_recode[] =
- {
- 0x20,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0x22,0xa9,0xaa,0xab,0x3f,0x3f,0xae,0x3f,
-
- 0xb0,0xb1,0xb2,0xb3,0x27,0xb5,0xb6,0xb7,0x2c,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf,
-
- 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,
-
- 0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf,
-
- 0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef,
-
- 0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff
-
- };
- #elif defined( MAPPER_D0D1 )
- #define MAPPER_D0D1_MOD
- const PROGMEM uint8_t utf_recode[] =
- {
- 0x41,0x80,0x42,0x92,0x81,0x45,0x82,0x83,0x84,0x85,0x4b,0x86,0x4d,0x48,0x4f,0x87,
-
- 0x50,0x43,0x54,0x88,0xd8,0x58,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x62,0x8f,0xac,0xad,
-
- 0x61,0x36,0x42,0x92,0x81,0x65,0x82,0xb3,0x84,0x85,0x6b,0x86,0x4d,0x48,0x6f,0x87,
-
- 0x70,0x63,0x54,0x79,0xd8,0x78,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x62,0x8f,0xac,0xad
-
- };
- #elif defined( MAPPER_E382E383 )
- #error( "Katakana on a western display makes no sense. There are no matching symbols." );
- #endif
-
- #elif defined( DISPLAY_CHARSET_HD44780_CYRILLIC )
- #if defined( MAPPER_D0D1 )
- #define MAPPER_D0D1_MOD
-
-
- const PROGMEM uint8_t utf_recode[] =
- { 0x41,0xa0,0x42,0xa1,0xe0,0x45,0xa3,0xa4,
-
- 0xa5,0xa6,0x4b,0xa7,0x4d,0x48,0x4f,0xa8,
-
- 0x50,0x43,0x54,0xa9,0xaa,0x58,0xe1,0xab,
-
- 0xac,0xe2,0xad,0xae,0x62,0xaf,0xb0,0xb1,
-
- 0x61,0xb2,0xb3,0xb4,0xe3,0x65,0xb6,0xb7,
-
- 0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0x6f,0xbe,
-
- 0x70,0x63,0xbf,0x79,0xe4,0x78,0xe5,0xc0,
-
- 0xc1,0xe6,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7
-
- };
- #elif defined( MAPPER_C2C3 )
- #error( "Western languages on a cyrillic display makes no sense. There are no matching symbols." );
- #elif defined( MAPPER_E382E383 )
- #error( "Katakana on a cyrillic display makes no sense. There are no matching symbols." );
- #endif
- #else
- #error("Something went wrong in the selection of DISPLAY_CHARSET_HD44780's");
- #endif
- #endif
-
- #if defined( MAPPER_NON )
- char charset_mapper(char c){
- HARDWARE_CHAR_OUT( c );
- return 1;
- }
- #elif defined( MAPPER_C2C3 )
- uint8_t utf_hi_char;
- bool seen_c2 = false;
- char charset_mapper(char c){
- uint8_t d = c;
- if ( d >= 0x80 ) {
- if ( (d >= 0xc0) && (!seen_c2) ) {
- utf_hi_char = d - 0xc2;
- seen_c2 = true;
- return 0;
- }
- else if (seen_c2){
- d &= 0x3f;
- #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_c2 = false;
- return 1;
- }
- #elif defined( MAPPER_D0D1_MOD )
- uint8_t utf_hi_char;
- bool seen_d5 = false;
- char charset_mapper(char c){
-
-
- uint8_t d = c;
- if ( d >= 0x80 ) {
- if ((d >= 0xd0) && (!seen_d5)) {
- utf_hi_char = d - 0xd0;
- seen_d5 = true;
- return 0;
- } else if (seen_d5) {
- d &= 0x3f;
- if ( !utf_hi_char && ( d == 1 )) {
- HARDWARE_CHAR_OUT((char) 0xa2 );
- } else if ((utf_hi_char == 1) && (d == 0x11)) {
- HARDWARE_CHAR_OUT((char) 0xb5 );
- } else {
- HARDWARE_CHAR_OUT((char) pgm_read_byte_near( utf_recode + d + ( utf_hi_char << 6 ) - 0x10 ) );
- }
- }
- else {
- HARDWARE_CHAR_OUT('?');
- }
- } else {
- HARDWARE_CHAR_OUT((char) c );
- }
- seen_d5 = false;
- return 1;
- }
- #elif defined( MAPPER_D0D1 )
- uint8_t utf_hi_char;
- bool seen_d5 = false;
- char charset_mapper(char c){
- uint8_t d = c;
- if ( d >= 0x80u ) {
- if ((d >= 0xd0u) && (!seen_d5)) {
- utf_hi_char = d - 0xd0u;
- seen_d5 = true;
- return 0;
- } else if (seen_d5) {
- d &= 0x3fu;
- #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) (0xa0u + ( utf_hi_char << 6 ) + d ) ) ;
- #endif
- } else {
- HARDWARE_CHAR_OUT('?');
- }
- } else {
- HARDWARE_CHAR_OUT((char) c );
- }
- seen_d5 = false;
- return 1;
- }
- #elif defined( MAPPER_E382E383 )
- uint8_t utf_hi_char;
- bool seen_e3 = false;
- bool seen_82_83 = false;
- char charset_mapper(char c){
- uint8_t d = c;
- if ( d >= 0x80 ) {
- if ( (d == 0xe3) && (seen_e3 == false)) {
- seen_e3 = true;
- return 0;
- } else if ( (d >= 0x82) && (seen_e3 == true) && (seen_82_83 == false)) {
- utf_hi_char = d - 0x82;
- seen_82_83 = true;
- return 0;
- } else if ((seen_e3 == true) && (seen_82_83 == true)){
- d &= 0x3f;
- #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((char) '?' );
- }
- } else {
- HARDWARE_CHAR_OUT((char) c );
- }
- seen_e3 = false;
- seen_82_83 = false;
- return 1;
- }
- #else
- #error "You have to define one of the DISPLAY_INPUT_CODE_MAPPERs in your language_xx.h file"
- #endif
-
- #endif
|