UTF8 in MODE 7

Discussions related specifically to the Windows, Linux (86), Mac OS-X and Raspberry Pi editions of BB4W and BBCSDL
User avatar
hellomike
Posts: 184
Joined: Sat 09 Jun 2018, 09:47
Location: Amsterdam

UTF8 in MODE 7

Post by hellomike »

Yes, I know, of course teletext is not designed for this :lol:

However I found that the UTF8 charset specified using VDU 23 is not reset after a MODE statement!
I'm not sure if this is intended functionality because if I want UTF8 in MODE 0, I can do:

Code: Select all

      VDU 23, 22, 8; 8; 8, 8, 8, 8, 22, 0
      PRINT '"Test " CHR$&C3 CHR$&91
The teletext mode however seems to lose its block graphics.

Code: Select all

      MODE 7
      PRINT "A red box:"CHR$145;CHR$247;CHR$251
      IF GET
      VDU 23, 22, 8; 8; 8, 8, 8, 8, 22, 7
      PRINT "Not A red box:"CHR$145;CHR$247;CHR$251
I tested this both in BB4W and BBCSDL.

Maybe my observation can benefit or warn others.

Regards,

Mike
Hated Moron

Re: UTF8 in MODE 7

Post by Hated Moron »

hellomike wrote: Thu 14 Sep 2023, 10:39 I'm not sure if this is intended functionality
It is, it's 'by design'. As you guessed, one specific use is to enable the UTF-8 character set in MODE 7. Exactly that combination is used by the Ceefax.bbc example program, here's a snippet of the code:

Code: Select all

      REM Select a 'teletext' video mode with support for UTF-8 pound sign:
      VDU 23,22,640;500;16,20,16,128+8
      MODE 7 : OFF
(no, I don't know why the 128 is there either, it's superfluous).
The teletext mode however seems to lose its block graphics.
Not necessarily, it depends on how you create them. For example this code works and draws a red box whilst the UTF-8 character set is active (make sure Unicode is enabled in the IDE):

Code: Select all

      VDU 23, 22, 8; 8; 8, 8, 8, 8, 22, 7
      PRINT "A red box:"CHR$27;CHR$145;CHR$27;CHR$247;CHR$27;CHR$251
      PRINT "Some UTF-8 pound signs £££££"
If you look at Ceefax.bbc you will see that all teletext control codes are preceded by a CHR$27 so that they will not interfere with the UTF-8 character encoding. You can always do that of course, but in regular MODE 7 it's optional whereas in UTF-8 mode it's mandatory.
User avatar
hellomike
Posts: 184
Joined: Sat 09 Jun 2018, 09:47
Location: Amsterdam

Re: UTF8 in MODE 7

Post by hellomike »

Always learning nieuw BBCBASIC snippets.

Thanks