Ticket #86 (new enhancement)

Opened 1 year ago

Last modified 1 year ago

Handle coding declarations

Reported by: otaylor Assigned to:
Priority: moderate Keywords:
Cc:

Description

  • On load, we should detect and honor coding declarations according to the Python rules. (Including the UTF-8 BOM. See PEP 0263, PEP 3120) If the coding declaration doesn't match the file contents, then the existing handling for utf-8 where we ask the user if they want to convert invalid byte sequences to escapes should work.
  • If there is no coding declaration, then use UTF-8 when loading the file
  • For libraries (not worksheets), with Python-2.x, if the file once loaded contains non-ascii, and has no coding declaration, prompt the user and offer to add a utf-8 coding declaration. (worth it? this is a definite corner case - might be encountered if someone is swotching between Python 3.x and a 2.x version of Reinteract.)
  • On save, honor any coding declaration found. If converting to that encoding produces an error, offer the user to switch the coding declaration to UTF-8. (The two options are to cancel or switch the coding declaration... no third choice)
  • For libraries with Python-2.x, if the file contains non-ascii and there is no coding declaration, offer to add a utf-8 coding declaration.

Change History

04/08/09 04:42:23 changed by akaihola

If a UTF-8 coding declaration can be automatically added when saving a library (bullet 5), I don't think the same is necessary when loading (bullet 3).