Re: substrb and MBCS

From: <michael.young_at_paetec.com>
Date: Mon, 4 Feb 2008 18:05:33 -0800 (PST)
Message-ID: <cd37cfa3-7b95-45f4-9b70-cc5be23beb5a@f10g2000hsf.googlegroups.com>


After a little more thought, I've changed a few details - just for efficiency - see the example code below (not tested)... however, this is not an optimal solution; I'd definitely prefer a definitive way to avoid splitting a character without all this extra effort... If anyone has a better way, or knows more about the behavior of substrb, I'd greatly appreciate any input.

v_max_text_byte_length integer := 2048 ;

MAX_CHARACTER_BYTE_LENGTH constant integer := 4 ;

diff := trunc( ( ( lengthb( src_msg ) - v_max_text_byte_length ) / MAX_CHARACTER_BYTE_LENGTH ), 0 ) ; if ( diff < 0 ) then

   tgt_msg := src_msg ;

else

   tgt_msg := substr( src_msg, 1, src_len - diff ) ;

   tgt_len_char := length( tgt_msg ) ;

   loop

      tgt_len := lengthb( tgt_msg ) ;
      exit when ( tgt_len <= 2048 ) ;
      tgt_len_char :=  tgt_len_char - 1 ;
      tgt_msg := substr( tgt_msg, 1, tgt_len_char ) ;

   end loop ;

end if ; Received on Mon Feb 04 2008 - 20:05:33 CST

Original text of this message