Support and General Use > Plugins/Viewers

(Fixed) Text viewer breaks multi-bytes characters

(1/1)

xhuang:
I have been having problem reading Chinese articles in my Sansa e250 because when a certain line is mixture of ascii chars and chinese chars the text viewer may break line in between a chinese charater which results the rest of the paragraph becomes unreadable.

After investigatng the source code of viewer.c I spotted the problem is at function

   unsigned char* get_ucs(const unsigned char* str, unsigned short* ch)

which, given the codepage is non-English, thinks the unicode size of an ascii char is 2. I fixed the problem by simply change this line:

  if ((prefs.encoding == SJIS && *str > 0xA0 && *str < 0xE0) || prefs.encoding < SJIS)

to

  if (*ch < 0x100 || (prefs.encoding == SJIS && *str > 0xA0 && *str < 0xE0) || prefs.encoding < SJIS)

Passed test on my Sansa e250.

Chronon:
Thank you.  The preferred method for submitting changes back for inclusion is to sign up for a Flyspray account and post a patch to the tracker.  (Follow the "patches" link on the sidebar.)

Navigation

[0] Message Index

Go to full version