.ad 8
.bm 8
.fm 4
.bt $Copyright (c) 2000-2004 SAP AG$$Page %$
.tm 12
.hm 6
.hs 3
.tt 1 $SQL$Project Distributed Database System$VGG20$
.tt 2 $$$
.tt 3 $HolgerB$Unicode-Utilities$1999-07-21$
***********************************************************
.nf
 
 
    ========== licence begin  GPL
    Copyright (c) 2000-2004 SAP AG
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    ========== licence end
 
.fo
.nf
.sp
MODULE  : Unicode-Utilities
=========
.sp
Purpose : trunc, fill ... for unicode
.CM *-END-* purpose -------------------------------------
.sp
.cp 3
Define  :
 
        PROCEDURE
              g20get_uni_key (
                    VAR setname   : tsp00_KnlIdentifier;
                    VAR messcode  : tsp00_CodeType;
                    VAR codewidth : tsp00_Uint1;
                    VAR rc        : tsp8_uni_error);
 
        PROCEDURE
              g20get_uni_set (
                    messcode      : tsp00_CodeType;
                    VAR codewidth : tsp00_Uint1;
                    VAR setname   : tsp00_KnlIdentifier);
 
        PROCEDURE
              g20unifill (
                    size      : tsp00_Int4;
                    m         : tsp00_MoveObjPtr (*ptocSynonym void**);
                    pos       : tsp00_Int4;
                    len       : tsp00_Int4;
                    filluchar : tsp00_C2 (*ptocSynonym const char**));
 
.CM *-END-* define --------------------------------------
.sp;.cp 3
Use     :
 
        FROM
              Configuration_Parameter : VGG01;
 
        PROCEDURE
              g01abort (
                    msg_no     : tsp00_Int4;
                    msg_label  : tsp00_C8;
                    msg_text   : tsp00_C24;
                    bad_value  : tsp00_Int4);
&       ifdef TRACE
 
      ------------------------------ 
 
        FROM
              Test_Procedures : VTA01;
 
        PROCEDURE
              t01buf (
                    debug    : tgg00_Debug;
                    VAR buf  : tsp00_KnlIdentifier;
                    startpos : integer;
                    endpos   : integer);
 
        PROCEDURE
              t01int4 (
                    debug    : tgg00_Debug;
                    nam      : tsp00_Sname;
                    int4     : tsp00_Int4);
&       endif
 
.CM *-END-* use -----------------------------------------
.sp;.cp 3
Synonym :
 
        PROCEDURE
              t01buf;
 
              tsp00_Buf tsp00_KnlIdentifier
 
.CM *-END-* synonym -------------------------------------
.sp;.cp 3
Author  : HolgerB
.sp
.cp 3
Created : 1992-08-07
.sp
.cp 3
Version : 2002-03-12
.sp
.cp 3
Release :      Date : 1999-07-21
.sp
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Specification:
 
.sp;.cp 7
.CM *-END-* specification -------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.fo
.oc _/1
Description:
.CM *-END-* description ---------------------------------
.sp 2
***********************************************************
.sp
.cp 10
.nf
.oc _/1
Structure:
 
.CM *-END-* structure -----------------------------------
.sp 2
**********************************************************
.sp
.cp 10
.nf
.oc _/1
.CM -lll-
Code    :
 
 
CONST
      c_ucs_2     =
            'UCS_2                                                           ';
      c_iso8859_1 =
            'ISO8859_1                                                       ';
 
 
(*------------------------------*) 
 
PROCEDURE
      g20get_uni_key (
            VAR setname   : tsp00_KnlIdentifier;
            VAR messcode  : tsp00_CodeType;
            VAR codewidth : tsp00_Uint1;
            VAR rc        : tsp8_uni_error);
 
BEGIN
rc       := uni_ok;
messcode := 0;
&ifdef TRACE
t01buf (ak_sem, setname, 1, sizeof(setname));
&endif
IF  setname = c_ucs_2
THEN
    BEGIN
    messcode  := csp_unicode;
    codewidth := 2
    END
ELSE
    IF  setname = c_iso8859_1
    THEN
        BEGIN
        messcode  := csp_ascii;
        codewidth := 1
        END
    ELSE
        rc := uni_no_such_encoding;
    (*ENDIF*) 
(*ENDIF*) 
&ifdef TRACE
t01int4 (ak_sem, 'messcode    ', messcode);
&endif
END;
 
(*------------------------------*) 
 
PROCEDURE
      g20get_uni_set (
            messcode      : tsp00_CodeType;
            VAR codewidth : tsp00_Uint1;
            VAR setname   : tsp00_KnlIdentifier);
 
BEGIN
IF  messcode in [ csp_unicode, csp_unicode_swap ]
THEN
    BEGIN
    setname   := c_ucs_2;
    codewidth := 2;
    END
ELSE
    BEGIN
    setname   := c_iso8859_1;
    codewidth := 1;
    END
(*ENDIF*) 
END;
 
(*------------------------------*) 
 
PROCEDURE
      g20unifill (
            size      : tsp00_Int4;
            m         : tsp00_MoveObjPtr;
            pos       : tsp00_Int4;
            len       : tsp00_Int4;
            filluchar : tsp00_C2);
 
VAR
      i     : integer;
 
BEGIN
IF  (size < pos + len - 1) OR
    (len < 0) OR (pos < 0)
THEN
    g01abort (csp3_g20x1_unifill, csp3_n_unicode,
          'invalid pos/len         ', len)
ELSE
    FOR i := 0 TO (len DIV 2) - 1 DO
        BEGIN
        m^ [ pos + (2*i) ]     := filluchar [ 1 ];
        m^ [ pos + (2*i) + 1 ] := filluchar [ 2 ];
        END;
    (*ENDFOR*) 
(*ENDIF*) 
END;
 
.CM *-END-* code ----------------------------------------
.SP 2 
***********************************************************
*-PRETTY-*  statements    :         21
*-PRETTY-*  lines of code :         92        PRETTYX 3.10 
*-PRETTY-*  lines in file :        276         1997-12-10 
.PA 
