code: private static final int getUnicodeStringLengthInBytes(byte[] data, int offset)
     {
        int result;
        if (data == null || offset >= data.length)
        {
           result = 0;
        }
        else
        {
           result = data.length - offset;
  
           for (int loop = offset; loop < (data.length - 1); loop += 2)
           {
              if (data[loop] == 0 && data[loop + 1] == 0)
              {
                 result = loop - offset;
                 break;
              }
           }
        }
        return result;
     }
docs: Determine the length of a nul terminated UTF16LE string in bytes.
  
  @param data string data
  @param offset offset into string data
  @return length in bytes