Filename character mapping

From BeebWiki
Revision as of 04:35, 3 April 2018 by Jgharston (talk | contribs) (.)
Jump to: navigation, search

When dealing with "foreign" media formats, such as zip files, DOS or Unix disks and images, etc., filenames can be encountered that contain characters that are not allowed on BBC filing systems, or have different meanings. The most common occurance is Unix, URLs and Zip files use / as a directory seperator whereas the BBC uses ., and the converse mapping of . and / as an extension seperator.

Other than DOS/Windows using \ directory seperators and Unix/URL/ZIP using / seperators, all non-BBC filename characters have the same meanings. The following tables show how different special characters are mapped between BBC and non-BBC platforms.

Non-BBC to BBC

The following characters are legal in DOS/Windows or Unix/URL/ZIP filenames, but are illegal or have special meanings in BBC filenames:

 Non-BBC    Non-BBC          BBC       Replace   Non-BBC      BBC
Character   Meaning        Meaning      with     Example    Example     Notes
---------------------------------------------------------------------------------
    #          -           wildcard       ?      part#3     part?3
    $          -           root dir       <      TEMP.$$$   TEMP/<<<
    %          -           lib dir        ;      TEMP.%%%   TEMP/;;;    see notes
    &          -           user dir       +      one&two    one+two     see notes
    *      wildcard        wildcard       *      info*      info*
    .      extension       directory      /      help.txt   help/txt
    .      current dir     directory      @      ./file     @.file      .\file on DOS
    ..     parent dir      directory      ^      ../menu    ^.menu      ..\file on DOS
    :      drive           drive          :      A:file     :A.file
    ?      wildcard            -          #      page??     page##
    @          -           current dir    =      TEMP.@@@   TEMP/===    see notes
    ^          -           parent dir     >      TEMP.^^^   TEMP/>>>
    
    /      Unix directory  extension   . or $    /dir/file  $.dir.file
    
    \      DOS directory       -       . or $    \dir\file  $.dir.file
    /      DOS -           extension      \      one/two    one\two

The simplest bidirectional mapping is:

 Non-BBC   BBC     DOS    BBC     Unix    BBC
-----------------------------------------------
    #  <->  ?       .  ->  /       .  <->  /
    $  <->  <       /  ->  \
    ^  <->  >       \  ->  .

BBC to Non-BBC

The following characters are legal in BBC filenames, but are illegal or have special meanings in DOS/Windows or Unix/URL/Zip filenames:

   BBC        BBC       Non-BBC       Replace    BBC      Non-BBC
Character   Meaning     Meaning        with    Example    Example          Notes
--------------------------------------------------------------------------------------
    #       wildcard        -            ?      part#3     part?3
    $       root dir        -            \      $.user     \user or /unix
    %       lib dir         -                   %.blib                     see notes
    &       user dir        -                   &.mymail                   see notes
    *       wildcard    wildcard         *      info*      info*
    :       drive       drive            :      :A.file    A:file
    <           -       redirection      $      TEMP/<<<   TEMP.$$$
    >           -       redirection      ^      TEMP/>>>   TEMP.^^^
    ?           -       wildcard         #      why?       why#
    @       current dir     -            .      @.file     .\file  or ./file
    ^       parent dir      -            ..     ^.file     ..\file or ../file
    
    /       extension   Unix directory   .      help/txt   help.txt
    .       directory   Unix extension   /      dir.file   dir/file
    
    .       directory   DOS extension    \      dir.file   dir\file
    /       extension   DOS -            .      help/txt   help.txt
    \           -       DOS directory    /      one\two    one/two

The simplest bidirectional mapping is:

   BBC   Non-BBC   BBC    DOS     BBC    Unix
-----------------------------------------------
    ?  <->  #       .  ->  \       .  <->  /
    <  <->  $       \  ->  /
    >  <->  ^       /  ->  .

DOS to/from UNIX

Included for completeness is mapping between DOS/Windows and Unix/URL/ZIP filenames. Both use the same characters other than DOS/Windows using \ for directories and UNIX/URL/ZIP using /.

   DOS       Unix         DOS       Replace    DOS           Unix
Character   Meaning     Meaning      with    Example        Example
--------------------------------------------------------------------------------------
   /       directory       -          \      \dir\file.txt  /dir/file.txt
   \           -       directory      /      one/two.txt    one\two.txt

The bidirection mapping is:

   DOS    Unix
---------------------
    /  <->  \

Notes

  • BBC & and % would be mapped to something like $HOMEDIR$ and $PATH$.
  • The mapping of non-BBC %, & and @ to BBC ;, + and = means that BBC ;, + and = have a one-to-two non-reversable mapping.

Implementations

  • RISC OS DOSFS translates bidirectionally between DOS %, &, @ and BBC ;=, ;~, ;=. However, BBC %, &, ; are also mapped to DOS %, &, ;, creating a non-reversable two-to-one mapping.
  • BBC DOSFS has not yet been tested.
  • SparkFS Zip only maps bidirectionally between . and /. All other mapping is Zip to BBC only, eg a Zip # is extracted as a ?, but a ? is stored back in a Zip unchanged as a ?.
  • BBCZip performs all four bidirectional character mappings # <-> ?, $ <-> <, ^ <-> >,. <-> /.
  • Other Zip implementations have not yet been tested.


SparkFS Zip

 SparkFS ZIP to BBC
 ------------------
 20_ _   21_!_   22_"_   23_?_   24_<_   25_;_   26_+_   27_'_
 28_(_   29_)_   2A_*_   2B_+_   2C_,_   2D_-_   2E_/_   2F_._ 
 30_0_   31_1_   32_2_   33_3_   34_4_   35_5_   36_6_   37_7_  
 38_8_   39_9_   3A_:_   3B_;_   3C_<_   3D_=_   3E_>_   3F_?_ 
 40_=_   41_A_   42_B_   43_C_   44_D_   45_E_   46_F_   47_G_ 
 48_H_   49_I_   4A_J_   4B_K_   4C_L_   4D_M_   4E_N_   4F_O_ 
 50_P_   51_Q_   52_R_   53_S_   54_T_   55_U_   56_V_   57_W_ 
 58_X_   59_Y_   5A_Z_   5B_[_   5C_._   5D_]_   5E_>_   5F___ 
 60_`_   61_a_   62_b_   63_c_   64_d_   65_e_   66_f_   67_g_ 
 68_h_   69_i_   6A_j_   6B_k_   6C_l_   6D_m_   6E_n_   6F_o_ 
 70_p_   71_q_   72_r_   73_s_   74_t_   75_u_   76_v_   77_w_ 
 78_x_   79_y_   7A_z_   7B_{_   7C_|_   7D_}_   7E_~_  
 BBC to SparkFS ZIP
 ------------------
 20_ _   21_!_   22_"_   23_#_   24_$_   25_%_   26_&_   27_'_
 28_(_   29_)_   2A_*_   2B_+_   2C_,_   2D_-_   2E_/_   2F_._ 
 30_0_   31_1_   32_2_   33_3_   34_4_   35_5_   36_6_   37_7_  
 38_8_   39_9_   3A_:_   3B_;_   3C_<_   3D_=_   3E_>_   3F_?_ 
 40_=_   41_A_   42_B_   43_C_   44_D_   45_E_   46_F_   47_G_ 
 48_H_   49_I_   4A_J_   4B_K_   4C_L_   4D_M_   4E_N_   4F_O_ 
 50_P_   51_Q_   52_R_   53_S_   54_T_   55_U_   56_V_   57_W_ 
 58_X_   59_Y_   5A_Z_   5B_[_   5C_  D  5D_]_   5E_>_   5F___ 
 60_`_   61_a_   62_b_   63_c_   64_d_   65_e_   66_f_   67_g_ 
 68_h_   69_i_   6A_j_   6B_k_   6C_l_   6D_m_   6E_n_   6F_o_ 
 70_p_   71_q_   72_r_   73_s_   74_t_   75_u_   76_v_   77_w_ 
 78_x_   79_y_   7A_z_   7B_{_   7C_|_   7D_}_   7E_~_  
 Mapping
 -------
 ZIP  -  BBC  -  ZIP
  #   ->  ?   ->  ?
  $   ->  <   ->  <
  %   ->  ;   ->  ;
  &   ->  +   ->  +
  .  <->  /
  /  <->  .
  @   ->  =   ->  =
  \   ->  .
  ^   ->  >   ->  >
          #   -> error
          $   -> error
          %   ->  %
          &   -> error
          @   ->  @
          \   ->
          ^   -> error

See also