home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / rxjis096.zip / pc2jis.cmd < prev    next >
OS/2 REXX Batch file  |  1997-08-09  |  2KB  |  67 lines

  1. /* product name: RXJIS                                                */
  2. /* Version:      0.90                                                 */
  3. /* author:       YANO Takashi                                         */
  4. /* target:       OS/2 Warp J3.0+ (J2.1 is possible)                   */
  5. /* source name:  PC2JIS.CMD                                           */
  6. /* address:      tyano@ca2.so-net.or.jp or tyano@yamato.ibm.co.jp     */
  7. /* comment:      RXJIS is a utility functions for REXX.               */
  8. /*               This header file is a interface to be called from    */
  9. /*               C/C++.                                               */
  10. /* History:                                                           */
  11. /*                                                                    */
  12. /* This is a part of build tool.                                      */
  13. arg fn
  14. if fn = '' then fn = 'pc2jis.dat'
  15. parse var fn cfn '.' .
  16. cfn = cfn || '.cpp'
  17. tb. = 0
  18. do while lines(fn)
  19.    parse value linein(fn) with ku tn
  20.    if tn = '' then tn = 1 94
  21.    do while tn <> ''
  22.       parse var tn m n tn
  23.       do t = m to n
  24.          j = d2x(ku + 32) || d2x(t + 32)
  25.          c = jistopc(j)
  26.          h = x2d(left(c, 2)) + 1
  27.          l = x2d(right(c, 2)) + 1
  28.          tb.h = 1
  29.          tb.h.l = j
  30.       end /* do */
  31.    end /* do */
  32. end /* do */
  33. call SysFileDelete cfn
  34. call lineout cfn, '#include <limits.h>'
  35. call lineout cfn, '#include <os2.h>'
  36. call lineout cfn, '#include "pc2jis.hpp"'
  37. call lineout cfn, '#pragma data_seg(rxjistbl)'
  38. do i = 1 to 256
  39.    if tb.i = 0 then iterate
  40.    call lineout cfn, 'static const wchar_t pccode2jiscode_' || d2x(i - 1) || '[UCHAR_MAX+1] = {'
  41.    do j = 1 to 256
  42.       if tb.i.j = 0 then call lineout cfn, '0x222e,'
  43.       else call lineout cfn, '0x' || tb.i.j || ','
  44.    end /* do */
  45.    call lineout cfn, '};'
  46. end /* do */
  47. call lineout cfn, 'const wchar_t _Export *PcCodeToJisCodeTable[UCHAR_MAX+1] = {'
  48. do i = 1 to 256
  49.    if tb.i = 0 then call lineout cfn, 'NULL,'
  50.    else call lineout cfn, 'pccode2jiscode_' || d2x(i - 1) || ','
  51. end /* do */
  52. call lineout cfn, '};'
  53. call stream cfn, 'c', 'close'
  54. exit
  55.  
  56. jistopc: procedure
  57. arg c
  58. h = x2d(left(c, 2))
  59. l = x2d(right(c, 2))
  60. if h // 2 = 1 then l = l + x2d('1f')
  61. else l = l + x2d('7d')
  62. if l >= x2d('7f') then l = l + 1
  63. h = (h - x2d('21')) % 2
  64. if h > x2d('1e') then h = h + x2d('c1')
  65. else h = h + x2d('81')
  66. return d2x(h) || d2x(l)
  67.