// 2011.02.13 # Doj
// Модуль для упрощения создания кодировок

include" units\structures\arr.de"

: encoding-table-to-unicode ( s-p) " char-" cswap str+ " ->unicode" str+ 
  created here 0 , 
  does> ( i-i) @ swap cells + @ ;
: encoding-table-from-unicode ( s-p) " char-unicode->" cswap str+ created here 0 , 
  does> ( i-i) @ 0 begin dup 256 < while 
      over @ 4 pick 
      = if rrot drop drop exit then 1+ swap cell+ swap 
    repeat ( i p i) drop drop drop 0 ;
: encoding-table source-next-name-passive encoding-table-to-unicode 
                 source-next-name-passive encoding-table-from-unicode
                 create here swap ! here swap ! ;

// namespace ENCODING
//   variable *last-table-encoding*
//   : create-tounicode str0 created here 0 , last does> @ swap cells + @ ;
//   : create-fromunicode str0 created here 0 , last 
//     does> @ begin over over dup @ lrot <> while cell+ ( ...) repeat ;
//   : table-encoding ( "name" -- ) create-tounicode create-fromunicode 
//     create lrot xt, xt, here swap embro! here swap embro! 256 cells allot ;
//   : , ( ii-) *last-table-encoding* arr! ;
// /namespace
