code: public static int calculateEncodedStringLength(String s)
     {
        if(TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "calculateEncodedStringLength", s);
  
        final int length;
  
        if(s == null)
        {
           length = 3;
        }
        else
        {
           try
           {
              final byte[] stringAsBytes = s.getBytes(stringEncoding);
              length = stringAsBytes.length + 2;
           }
           catch (UnsupportedEncodingException e)
           {
              FFDCFilter.processException(e, CLASS_NAME + ".calculateEncodedStringLength", CommsConstants.COMMSBYTEBUFFER_CALC_ENC_STRLEN_01);
  
              if(TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "Unable to encode String: ", e);
  
              SibTr.error(tc, "UNSUPPORTED_STRING_ENCODING_SICO8023", new Object[] {stringEncoding, e});
  
              throw new SIErrorException(
                 TraceNLS.getFormattedMessage(CommsConstants.MSG_BUNDLE, "UNSUPPORTED_STRING_ENCODING_SICO8023", new Object[] {stringEncoding, e}, null)
              );
           }
        }
  
        if(TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "calculateEncodedStringLength", Integer.valueOf(length));
        return length;
     }
docs: Calculates the length in bytes of a String when it is placed inside a CommsByteBuffer via the putString method.
  A null String can be passed into this method.
  
  @param s the String to calculate the length of.
  @return the number of bytes that the String will take up when encoded.