home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 8 Other
/
08-Other.zip
/
rxjis096.zip
/
pc2jis.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1997-08-09
|
2KB
|
67 lines
/* product name: RXJIS */
/* Version: 0.90 */
/* author: YANO Takashi */
/* target: OS/2 Warp J3.0+ (J2.1 is possible) */
/* source name: PC2JIS.CMD */
/* address: tyano@ca2.so-net.or.jp or tyano@yamato.ibm.co.jp */
/* comment: RXJIS is a utility functions for REXX. */
/* This header file is a interface to be called from */
/* C/C++. */
/* History: */
/* */
/* This is a part of build tool. */
arg fn
if fn = '' then fn = 'pc2jis.dat'
parse var fn cfn '.' .
cfn = cfn || '.cpp'
tb. = 0
do while lines(fn)
parse value linein(fn) with ku tn
if tn = '' then tn = 1 94
do while tn <> ''
parse var tn m n tn
do t = m to n
j = d2x(ku + 32) || d2x(t + 32)
c = jistopc(j)
h = x2d(left(c, 2)) + 1
l = x2d(right(c, 2)) + 1
tb.h = 1
tb.h.l = j
end /* do */
end /* do */
end /* do */
call SysFileDelete cfn
call lineout cfn, '#include <limits.h>'
call lineout cfn, '#include <os2.h>'
call lineout cfn, '#include "pc2jis.hpp"'
call lineout cfn, '#pragma data_seg(rxjistbl)'
do i = 1 to 256
if tb.i = 0 then iterate
call lineout cfn, 'static const wchar_t pccode2jiscode_' || d2x(i - 1) || '[UCHAR_MAX+1] = {'
do j = 1 to 256
if tb.i.j = 0 then call lineout cfn, '0x222e,'
else call lineout cfn, '0x' || tb.i.j || ','
end /* do */
call lineout cfn, '};'
end /* do */
call lineout cfn, 'const wchar_t _Export *PcCodeToJisCodeTable[UCHAR_MAX+1] = {'
do i = 1 to 256
if tb.i = 0 then call lineout cfn, 'NULL,'
else call lineout cfn, 'pccode2jiscode_' || d2x(i - 1) || ','
end /* do */
call lineout cfn, '};'
call stream cfn, 'c', 'close'
exit
jistopc: procedure
arg c
h = x2d(left(c, 2))
l = x2d(right(c, 2))
if h // 2 = 1 then l = l + x2d('1f')
else l = l + x2d('7d')
if l >= x2d('7f') then l = l + 1
h = (h - x2d('21')) % 2
if h > x2d('1e') then h = h + x2d('c1')
else h = h + x2d('81')
return d2x(h) || d2x(l)