From b0fee17d6e1a463dcd84568e5997663b69488998 Mon Sep 17 00:00:00 2001 From: Marcoen Hirschberg Date: Tue, 6 Dec 2005 13:27:15 +0000 Subject: waiting is over: initial unicode commit git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8169 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/lcd-player.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'firmware/drivers/lcd-player.c') diff --git a/firmware/drivers/lcd-player.c b/firmware/drivers/lcd-player.c index 566c868d7f..d01ec3447f 100644 --- a/firmware/drivers/lcd-player.c +++ b/firmware/drivers/lcd-player.c @@ -31,6 +31,7 @@ #include "system.h" #include "font.h" #include "lcd-player-charset.h" +#include "rbunicode.h" /*** definitions ***/ @@ -323,9 +324,24 @@ static void lcd_puts_cont_scroll(int x, int y, const unsigned char *string) } void lcd_puts(int x, int y, const unsigned char *string) { + int i=0; + unsigned short ucs; + const unsigned char *utf8 = string; + unsigned char tmp[12]; + + while (*utf8 && i<11) { + utf8 = utf8decode(utf8, &ucs); + if (ucs < 256) + tmp[i++] = ucs; + else + tmp[i++] = '?'; + } + + tmp[i] = 0; + DEBUGF("lcd_puts(%d, %d) -> ", x, y); scroll[y].mode=SCROLL_MODE_OFF; - return lcd_puts_cont_scroll(x, y, string); + return lcd_puts_cont_scroll(x, y, tmp); } void lcd_put_cursor(int x, int y, char cursor_char) @@ -627,14 +643,28 @@ void lcd_bidir_scroll(int percent) void lcd_puts_scroll(int x, int y, const unsigned char* string ) { struct scrollinfo* s; - int i; + int i=0; + unsigned short ucs; + const unsigned char *utf8 = string; + unsigned char tmp[utf8length(string)+1]; + + while (*utf8) { + utf8 = utf8decode(utf8, &ucs); + if (ucs < 256) + tmp[i++] = ucs; + else + tmp[i++] = '?'; + } + + tmp[i] = 0; + DEBUGF("lcd_puts_scroll(%d, %d, %s)\n", x, y, string); s = &scroll[y]; - lcd_puts_cont_scroll(x,y,string); - s->textlen = strlen(string); + lcd_puts_cont_scroll(x,y,tmp); + s->textlen = strlen(tmp); if ( s->textlen > 11-x ) { s->mode = SCROLL_MODE_RUN; @@ -649,7 +679,7 @@ void lcd_puts_scroll(int x, int y, const unsigned char* string ) s->jump_scroll_steps=11-x; s->jump_scroll=jump_scroll; } - strncpy(s->text,string,sizeof s->text); + strncpy(s->text,tmp,sizeof s->text); s->turn_offset=-1; if (bidir_limit && (s->textlen < ((11-x)*(100+bidir_limit))/100)) { s->turn_offset=s->textlen+x-11; -- cgit v1.2.3