home *** CD-ROM | disk | FTP | other *** search
- definit
- universal country
- universal codepage
- universal dbcsvec
- universal ondbcs
-
- inp=atol(0)
- buf=copies(\0, 38)
- ret=\0\0
- call dynalink('NLS', 'DOSGETCTRYINFO',
- atoi(length(buf)) ||
- selector(inp)offset(inp) ||
- selector(buf)offset(buf) ||
- selector(ret)offset(ret),
- 1)
- country=itoa(substr(buf,1,2),10)
- codepage=itoa(substr(buf,3,2),10)
- inp=atol(0)
- dbcsvec=copies(\0, 10)
- call dynalink('NLS', 'DOSGETDBCSEV',
- atoi(length(dbcsvec)) ||
- selector(inp)offset(inp) ||
- selector(dbcsvec)offset(dbcsvec),
- 1)
- ondbcs = leftstr(dbcsvec, 2) <> atoi(0)
-
- defproc isdbcs(c)
- universal dbcsvec, ondbcs
- if not ondbcs then
- return 0
- endif
- c=leftstr(c,1)
- for i = 1 to length(dbcsvec) by 2
- if substr(dbcsvec,i,2)=atoi(0) then
- leave
- endif
- if substr(dbcsvec, i, 1) <= c and c <= substr(dbcsvec, i + 1, 1) then
- return 1
- endif
- endfor
- return 0
-
- defproc whatisit(s, p)
- l = length(s)
- i = 1
- while i <= l do
- if i > p then
- leave
- endif
- if isdbcs(substr(s, i, 1)) then
- if i = p then
- return 1 -- DBCS 1st
- elseif i + 1 = p then
- return 2 -- DBCS 2nd
- else
- i = i + 2
- endif
- else
- i = i + 1
- endif
- endwhile
- return 0 -- SBCS
-