home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / prodtool / epm / e_macros / epmdbcs.e < prev    next >
Encoding:
Text File  |  1991-03-14  |  1.5 KB  |  63 lines

  1. definit
  2.    universal country
  3.    universal codepage
  4.    universal dbcsvec
  5.    universal ondbcs
  6.  
  7.    inp=atol(0)
  8.    buf=copies(\0, 38)
  9.    ret=\0\0
  10.    call dynalink('NLS', 'DOSGETCTRYINFO',
  11.                  atoi(length(buf)) ||
  12.                  selector(inp)offset(inp) ||
  13.                  selector(buf)offset(buf) ||
  14.                  selector(ret)offset(ret),
  15.                  1)
  16.    country=itoa(substr(buf,1,2),10)
  17.    codepage=itoa(substr(buf,3,2),10)
  18.    inp=atol(0)
  19.    dbcsvec=copies(\0, 10)
  20.    call dynalink('NLS', 'DOSGETDBCSEV',
  21.                  atoi(length(dbcsvec)) ||
  22.                  selector(inp)offset(inp) ||
  23.                  selector(dbcsvec)offset(dbcsvec),
  24.                   1)
  25.    ondbcs = leftstr(dbcsvec, 2) <> atoi(0)
  26.  
  27. defproc isdbcs(c)
  28.    universal dbcsvec, ondbcs
  29.    if not ondbcs then
  30.       return 0
  31.    endif
  32.    c=leftstr(c,1)
  33.    for i = 1 to length(dbcsvec) by 2
  34.       if substr(dbcsvec,i,2)=atoi(0) then
  35.          leave
  36.       endif
  37.       if substr(dbcsvec, i, 1) <= c and c <= substr(dbcsvec, i + 1, 1) then
  38.          return 1
  39.       endif
  40.    endfor
  41.    return 0
  42.  
  43. defproc whatisit(s, p)
  44.    l = length(s)
  45.    i = 1
  46.    while i <= l do
  47.       if i > p then
  48.          leave
  49.       endif
  50.       if isdbcs(substr(s, i, 1)) then
  51.          if i = p then
  52.             return 1 -- DBCS 1st
  53.          elseif i + 1 = p then
  54.             return 2 -- DBCS 2nd
  55.          else
  56.             i = i + 2
  57.          endif
  58.       else
  59.          i = i + 1
  60.       endif
  61.    endwhile
  62.    return 0 -- SBCS
  63.