diff options
author | Dmitry Mikhirev | 2012-08-29 01:26:25 +0400 |
---|---|---|
committer | Dmitry Mikhirev | 2012-08-29 01:26:25 +0400 |
commit | 24ebbd942c0cc2557b43fb54e058d967cc28f3b3 (patch) | |
tree | a76ac0e9da47ee0e2b4c74d0503740e127010597 /lcdprint.cpp | |
parent | f809838486400ed169c47466559d7fbd01f6c2ce (diff) | |
download | brainuino-24ebbd942c0cc2557b43fb54e058d967cc28f3b3.tar.gz brainuino-24ebbd942c0cc2557b43fb54e058d967cc28f3b3.tar.bz2 brainuino-24ebbd942c0cc2557b43fb54e058d967cc28f3b3.tar.xz brainuino-24ebbd942c0cc2557b43fb54e058d967cc28f3b3.zip |
fix UTF-8 strings conversion
Diffstat (limited to 'lcdprint.cpp')
-rw-r--r-- | lcdprint.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lcdprint.cpp b/lcdprint.cpp index 585b2de..c79bb1c 100644 --- a/lcdprint.cpp +++ b/lcdprint.cpp @@ -17,12 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ - +#include <LiquidCrystal.h> #include "lcdprint.h" -#include "font_ru-en.h" -//#include "font_en.h" +#include "font.h" -char* convert(utf8 str) +size_t uprint(utf8 str, LiquidCrystal *lcd) { int32_t ucode; int i, j; @@ -36,9 +35,9 @@ char* convert(utf8 str) result[i] = char(ucode); } else { result[i] = 0xff; - for (j = 0; j < numcodes && charmap[j].uni < ucode; j++) { - if (charmap[j].uni == ucode) { - result[i] = charmap[j].font; + for (j = 0; (j < numcodes) && (pgm_read_dword(&charmap[j].uni) <= ucode); j++) { + if (pgm_read_dword(&charmap[j].uni) == ucode) { + result[i] = pgm_read_byte(&charmap[j].font); } } } @@ -47,6 +46,5 @@ char* convert(utf8 str) break; } } - - return result; + return lcd->print(result); } |