tom-seddon / b2

BBC Micro emulator for Windows, OS X, and Linux
112 stars 13 forks source link

Copying BASIC listing exports wrong characters #333

Open yqxq opened 5 months ago

yqxq commented 5 months ago

The export of BASIC listings to the clipboard delivers straight byte-exact export of the Teletext ASCII, where it should be remapped to UTF8. You can use this as lookup table to convert to correct UTF-8: char BBC_ASCII[]={ ' ','!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/', //0x2f '0','1','2' ,'3','4','5','6','7','8','9',':',';','<','=','>','?', //0x3f ' ','A','B' ,'C','D','E','F','G','H','I','J','K','L','M','N','O', //0x4f 'P','Q','R' ,'S','T','U','V','W','X','Y','Z','←','½','→','↑','-', //0x5f '£','a','b' ,'c','d','e','f','g','h','i','j','k','l','m','n','o', //0x6f 'p','q','r' ,'s','t','u','v','w','x','y','z','¼','‖','¾','÷','█'};

Well, in a way it is not straigth byte-map completely as - becomes C2A3 and renders as £

tom-seddon commented 5 months ago

Yes, £ should definitely be converted - I'm not sure why I didn't make it do that already, sorry.

Regarding the teletext characters, the way it currently works is actually correct, as everything is defined based on the ASCII values and their appearance in Modes 0-6. These characters are displayed wrong in Mode 7, and everybody just ignores that!

But this could be a bit unhelpful for strings sometimes, as you might actually want some of the arrow or fraction characters. So it should really be an option.

(All of this stuff would then translate back on the way in if pasting via the menu. So (say) [ and would be interchangeable, and both would be treated as [. You'd also be able to supply a ` or £ if you wanted £ on the BBC end.)

tom-seddon commented 5 months ago

For _, maybe use U+2015 ― horizontal bar?