在C#中,我們可以這樣轉換:
int a=203;
char b=(char)a;
label1.text=b.toString();
現在我需要把這段算法用procedures完成,這個時候問題就來了,在procedures裏面,轉換的卻是一個為空的字符,而單純用
select chr(203) from dual,卻又沒問題,這裡大蝦多,望知道的弟兄點撥小弟一下:
代碼如下:
ROCEDURE CLS_CODE128A
   ( p_code IN varchar2,
     r_code out varchar2)
   IS
    
    code128aStart_int number;
    code128aStop_int  number;
    code128aStart_char char;
    code128aStop_char char;
    code128aCheck char;
    WeightedTotal number;
    p_code_length number;
    icurrentchar  number;
 
BEGIN
    r_code :='';
    code128aStart_int:=203;
    code128aStop_int:=206;
    WeightedTotal:=code128aStart_int-100;
    select chr(203) into code128aStart_char from dual;
    --dbms_output.put_line(code128aStart_char);
    select chr(206) into code128aStop_char from dual;
    WeightedTotal:=code128aStart_int-100;
    p_code_length:=length(p_code);
    for idx in 1..p_code_length loop
        icurrentchar:=ascii(substr(p_code,idx,1));  
        --dbms_output.put_line(icurrentchar); 
        if icurrentchar <135 then
            icurrentchar :=icurrentchar-32;
        else if icurrentchar >134 then
            icurrentchar :=icurrentchar-100;
            end if;
        end if;
        WeightedTotal:=WeightedTotal+(icurrentchar*(idx+1));
    end loop;
    icurrentchar :=mod(WeightedTotal,103);
    if icurrentchar <95 and icurrentchar >0 then
     icurrentchar :=icurrentchar+32;
    else if icurrentchar >94 then
     icurrentchar :=icurrentchar+100;
     else if icurrentchar=0 then
      icurrentchar :=194;
      end if;
     end if;
    end if;
    code128aCheck:= chr(icurrentchar);
    for idx1 in 1..p_code_length loop
        if substr(p_code,idx1,1)=chr(194) then
            r_code:=r_code||chr(194);
        else
            r_code:=r_code||substr(p_code,idx1,1);
        end if;
    end loop;
    r_code:=code128aStart_char||r_code||code128aCheck||code128aStop_char;
    
EXCEPTION
    WHEN others THEN
    r_code:='ERR';
END; -- Procedure