Merge pull request #4281 from AnHardt/lang-system
Don't use UTF-strlen() if the text is not UTF
This commit is contained in:
commit
2b9515d60f
20 changed files with 19 additions and 35 deletions
|
@ -30,7 +30,6 @@
|
||||||
#ifndef LANGUAGE_AN_H
|
#ifndef LANGUAGE_AN_H
|
||||||
#define LANGUAGE_AN_H
|
#define LANGUAGE_AN_H
|
||||||
|
|
||||||
#define MAPPER_NON
|
|
||||||
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
||||||
//#define SIMULATE_ROMFONT
|
//#define SIMULATE_ROMFONT
|
||||||
#define DISPLAY_CHARSET_ISO10646_1
|
#define DISPLAY_CHARSET_ISO10646_1
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#ifndef LANGUAGE_CA_H
|
#ifndef LANGUAGE_CA_H
|
||||||
#define LANGUAGE_CA_H
|
#define LANGUAGE_CA_H
|
||||||
|
|
||||||
//#define MAPPER_NON
|
|
||||||
#define MAPPER_C2C3 // because of "ó"
|
#define MAPPER_C2C3 // because of "ó"
|
||||||
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
||||||
//#define SIMULATE_ROMFONT
|
//#define SIMULATE_ROMFONT
|
||||||
|
|
|
@ -29,8 +29,6 @@
|
||||||
*/
|
*/
|
||||||
#ifndef LANGUAGE_CN_H
|
#ifndef LANGUAGE_CN_H
|
||||||
#define LANGUAGE_CN_H
|
#define LANGUAGE_CN_H
|
||||||
|
|
||||||
#define MAPPER_NON // For direct ascii codes
|
|
||||||
#define DISPLAY_CHARSET_ISO10646_CN
|
#define DISPLAY_CHARSET_ISO10646_CN
|
||||||
|
|
||||||
#define WELCOME_MSG "\xa4\xa5\xa6\xa7"
|
#define WELCOME_MSG "\xa4\xa5\xa6\xa7"
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
#ifndef LANGUAGE_CZ_H
|
#ifndef LANGUAGE_CZ_H
|
||||||
#define LANGUAGE_CZ_H
|
#define LANGUAGE_CZ_H
|
||||||
|
|
||||||
#define MAPPER_NON
|
|
||||||
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
||||||
//#define SIMULATE_ROMFONT
|
//#define SIMULATE_ROMFONT
|
||||||
#define DISPLAY_CHARSET_ISO10646_1
|
#define DISPLAY_CHARSET_ISO10646_1
|
||||||
|
|
|
@ -35,10 +35,6 @@
|
||||||
#define DISPLAY_CHARSET_ISO10646_1 // use the better font on full graphic displays.
|
#define DISPLAY_CHARSET_ISO10646_1 // use the better font on full graphic displays.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DISABLED(MAPPER_NON) && DISABLED(MAPPER_C2C3) && DISABLED(MAPPER_D0D1) && DISABLED(MAPPER_D0D1_MOD) && DISABLED(MAPPER_E382E383) && DISABLED(MAPPER_CECF)
|
|
||||||
#define MAPPER_NON // For direct ascii codes
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef WELCOME_MSG
|
#ifndef WELCOME_MSG
|
||||||
#define WELCOME_MSG MACHINE_NAME " ready."
|
#define WELCOME_MSG MACHINE_NAME " ready."
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#ifndef LANGUAGE_ES_H
|
#ifndef LANGUAGE_ES_H
|
||||||
#define LANGUAGE_ES_H
|
#define LANGUAGE_ES_H
|
||||||
|
|
||||||
#define MAPPER_NON
|
|
||||||
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
||||||
//#define SIMULATE_ROMFONT
|
//#define SIMULATE_ROMFONT
|
||||||
#define DISPLAY_CHARSET_ISO10646_1
|
#define DISPLAY_CHARSET_ISO10646_1
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#ifndef LANGUAGE_EU_H
|
#ifndef LANGUAGE_EU_H
|
||||||
#define LANGUAGE_EU_H
|
#define LANGUAGE_EU_H
|
||||||
|
|
||||||
#define MAPPER_NON
|
|
||||||
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
||||||
//#define SIMULATE_ROMFONT
|
//#define SIMULATE_ROMFONT
|
||||||
#define DISPLAY_CHARSET_ISO10646_1
|
#define DISPLAY_CHARSET_ISO10646_1
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#ifndef LANGUAGE_FR_H
|
#ifndef LANGUAGE_FR_H
|
||||||
#define LANGUAGE_FR_H
|
#define LANGUAGE_FR_H
|
||||||
|
|
||||||
#define MAPPER_NON
|
|
||||||
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
||||||
//#define SIMULATE_ROMFONT
|
//#define SIMULATE_ROMFONT
|
||||||
#define DISPLAY_CHARSET_ISO10646_1
|
#define DISPLAY_CHARSET_ISO10646_1
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#ifndef LANGUAGE_HR_H
|
#ifndef LANGUAGE_HR_H
|
||||||
#define LANGUAGE_HR_H
|
#define LANGUAGE_HR_H
|
||||||
|
|
||||||
#define MAPPER_NON
|
|
||||||
|
|
||||||
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
||||||
//#define SIMULATE_ROMFONT
|
//#define SIMULATE_ROMFONT
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#ifndef LANGUAGE_IT_H
|
#ifndef LANGUAGE_IT_H
|
||||||
#define LANGUAGE_IT_H
|
#define LANGUAGE_IT_H
|
||||||
|
|
||||||
#define MAPPER_NON
|
|
||||||
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
||||||
//#define SIMULATE_ROMFONT
|
//#define SIMULATE_ROMFONT
|
||||||
#define DISPLAY_CHARSET_ISO10646_1
|
#define DISPLAY_CHARSET_ISO10646_1
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
#ifndef LANGUAGE_KANA_H
|
#ifndef LANGUAGE_KANA_H
|
||||||
#define LANGUAGE_KANA_H
|
#define LANGUAGE_KANA_H
|
||||||
|
|
||||||
#define MAPPER_NON
|
|
||||||
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
||||||
#define SIMULATE_ROMFONT
|
#define SIMULATE_ROMFONT
|
||||||
#define DISPLAY_CHARSET_ISO10646_KANA
|
#define DISPLAY_CHARSET_ISO10646_KANA
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#ifndef LANGUAGE_NL_H
|
#ifndef LANGUAGE_NL_H
|
||||||
#define LANGUAGE_NL_H
|
#define LANGUAGE_NL_H
|
||||||
|
|
||||||
#define MAPPER_NON
|
|
||||||
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
||||||
//#define SIMULATE_ROMFONT
|
//#define SIMULATE_ROMFONT
|
||||||
#define DISPLAY_CHARSET_ISO10646_1
|
#define DISPLAY_CHARSET_ISO10646_1
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#ifndef LANGUAGE_PL_H
|
#ifndef LANGUAGE_PL_H
|
||||||
#define LANGUAGE_PL_H
|
#define LANGUAGE_PL_H
|
||||||
|
|
||||||
#define MAPPER_NON
|
|
||||||
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
||||||
//#define SIMULATE_ROMFONT
|
//#define SIMULATE_ROMFONT
|
||||||
#define DISPLAY_CHARSET_ISO10646_1
|
#define DISPLAY_CHARSET_ISO10646_1
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#ifndef LANGUAGE_PT_BR_H
|
#ifndef LANGUAGE_PT_BR_H
|
||||||
#define LANGUAGE_PT_BR_H
|
#define LANGUAGE_PT_BR_H
|
||||||
|
|
||||||
#define MAPPER_NON
|
|
||||||
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
||||||
//#define SIMULATE_ROMFONT
|
//#define SIMULATE_ROMFONT
|
||||||
#define DISPLAY_CHARSET_ISO10646_1
|
#define DISPLAY_CHARSET_ISO10646_1
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#ifndef LANGUAGE_PT_BR_UTF_H
|
#ifndef LANGUAGE_PT_BR_UTF_H
|
||||||
#define LANGUAGE_PT_BR_UTF_H
|
#define LANGUAGE_PT_BR_UTF_H
|
||||||
|
|
||||||
#define MAPPER_NON
|
|
||||||
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
||||||
//#define SIMULATE_ROMFONT
|
//#define SIMULATE_ROMFONT
|
||||||
#define DISPLAY_CHARSET_ISO10646_1
|
#define DISPLAY_CHARSET_ISO10646_1
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#ifndef LANGUAGE_PT_H
|
#ifndef LANGUAGE_PT_H
|
||||||
#define LANGUAGE_PT_H
|
#define LANGUAGE_PT_H
|
||||||
|
|
||||||
#define MAPPER_NON
|
|
||||||
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
||||||
//#define SIMULATE_ROMFONT
|
//#define SIMULATE_ROMFONT
|
||||||
#define DISPLAY_CHARSET_ISO10646_1
|
#define DISPLAY_CHARSET_ISO10646_1
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#ifndef LANGUAGE_PT_UTF_H
|
#ifndef LANGUAGE_PT_UTF_H
|
||||||
#define LANGUAGE_PT_UTF_H
|
#define LANGUAGE_PT_UTF_H
|
||||||
|
|
||||||
#define MAPPER_NON
|
|
||||||
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
||||||
//#define SIMULATE_ROMFONT
|
//#define SIMULATE_ROMFONT
|
||||||
#define DISPLAY_CHARSET_ISO10646_1
|
#define DISPLAY_CHARSET_ISO10646_1
|
||||||
|
|
|
@ -46,11 +46,10 @@
|
||||||
// Kanji (an other Japanese symbol set) uses far more than two codepages. So currently I don't see a chance to map the Unicodes. Its not
|
// Kanji (an other Japanese symbol set) uses far more than two codepages. So currently I don't see a chance to map the Unicodes. Its not
|
||||||
// impossible to have a close to direct mapping but will need giant conversion tables and fonts (we don't want to have in a embedded system).
|
// impossible to have a close to direct mapping but will need giant conversion tables and fonts (we don't want to have in a embedded system).
|
||||||
|
|
||||||
|
|
||||||
#define MAPPER_NON // For direct ascii codes ( until now all languages except ru, de, fi, kana_utf8, ... )
|
|
||||||
//#define MAPPER_C2C3 // For most European languages when language file is in utf8
|
//#define MAPPER_C2C3 // For most European languages when language file is in utf8
|
||||||
//#define MAPPER_D0D1 // For Cyrillic
|
//#define MAPPER_D0D1 // For Cyrillic
|
||||||
//#define MAPPER_E382E383 // For Katakana
|
//#define MAPPER_E382E383 // For Katakana
|
||||||
|
//#define MAPPER_NON // For direct ascii codes. Fall back mapper - if no other is defined.
|
||||||
|
|
||||||
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
|
||||||
//#define SIMULATE_ROMFONT
|
//#define SIMULATE_ROMFONT
|
||||||
|
|
|
@ -2476,7 +2476,11 @@ void lcd_init() {
|
||||||
int lcd_strlen(const char* s) {
|
int lcd_strlen(const char* s) {
|
||||||
int i = 0, j = 0;
|
int i = 0, j = 0;
|
||||||
while (s[i]) {
|
while (s[i]) {
|
||||||
|
#ifdef MAPPER_NON
|
||||||
|
j++;
|
||||||
|
#else
|
||||||
if ((s[i] & 0xc0) != 0x80) j++;
|
if ((s[i] & 0xc0) != 0x80) j++;
|
||||||
|
#endif
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return j;
|
return j;
|
||||||
|
@ -2485,7 +2489,11 @@ int lcd_strlen(const char* s) {
|
||||||
int lcd_strlen_P(const char* s) {
|
int lcd_strlen_P(const char* s) {
|
||||||
int j = 0;
|
int j = 0;
|
||||||
while (pgm_read_byte(s)) {
|
while (pgm_read_byte(s)) {
|
||||||
|
#ifdef MAPPER_NON
|
||||||
|
j++;
|
||||||
|
#else
|
||||||
if ((pgm_read_byte(s) & 0xc0) != 0x80) j++;
|
if ((pgm_read_byte(s) & 0xc0) != 0x80) j++;
|
||||||
|
#endif
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
return j;
|
return j;
|
||||||
|
|
|
@ -146,14 +146,7 @@
|
||||||
#endif // DISPLAY_CHARSET_HD44780
|
#endif // DISPLAY_CHARSET_HD44780
|
||||||
#endif // SIMULATE_ROMFONT
|
#endif // SIMULATE_ROMFONT
|
||||||
|
|
||||||
#if ENABLED(MAPPER_NON)
|
#if ENABLED(MAPPER_C2C3)
|
||||||
|
|
||||||
char charset_mapper(char c) {
|
|
||||||
HARDWARE_CHAR_OUT( c );
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif ENABLED(MAPPER_C2C3)
|
|
||||||
|
|
||||||
char charset_mapper(char c) {
|
char charset_mapper(char c) {
|
||||||
static uint8_t utf_hi_char; // UTF-8 high part
|
static uint8_t utf_hi_char; // UTF-8 high part
|
||||||
|
@ -353,7 +346,12 @@
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#error "You have to define one of the DISPLAY_INPUT_CODE_MAPPERs in your language_xx.h file" // should not occur because (en) will set.
|
#define MAPPER_NON
|
||||||
|
|
||||||
|
char charset_mapper(char c) {
|
||||||
|
HARDWARE_CHAR_OUT( c );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // code mappers
|
#endif // code mappers
|
||||||
|
|
||||||
|
|
Reference in a new issue