ecma_op_advance_string_index (ecma_string_t *str_p, /**< input string */
                              ecma_length_t index, /**< given character index */
                              bool is_unicode) /**< true - if regexp object's "unicode" flag is set
                                                    false - otherwise */
{
  JERRY_ASSERT ((ecma_number_t) index <= ECMA_NUMBER_MAX_SAFE_INTEGER);
  ecma_length_t next_index = index + 1;

  if (!is_unicode)
  {
    return next_index;
  }

  lit_utf8_size_t str_len = ecma_string_get_length (str_p);

  if (next_index >= str_len)
  {
    return next_index;
  }

  JERRY_ASSERT (index < UINT32_MAX);
  ecma_char_t first = ecma_string_get_char_at_pos (str_p, (lit_utf8_size_t) index);

  if (!lit_is_code_point_utf16_high_surrogate (first))
  {
    return next_index;
  }

  ecma_char_t second = ecma_string_get_char_at_pos (str_p, (lit_utf8_size_t) next_index);

  if (!lit_is_code_point_utf16_low_surrogate (second))
  {
    return next_index;
  }

  return next_index + 1;
} /* ecma_op_advance_string_index */
ecma_op_advance_string_index (ecma_string_t *str_p,  
                              ecma_length_t index,  
                              bool is_unicode)  
{
  JERRY_ASSERT ((ecma_number_t) index <= ECMA_NUMBER_MAX_SAFE_INTEGER);
  ecma_length_t next_index = index + 1;

  if (!is_unicode)
  {
    return next_index;
  }

  lit_utf8_size_t str_len = ecma_string_get_length (str_p);

  if (next_index >= str_len)
  {
    return next_index;
  }

  JERRY_ASSERT (index < UINT32_MAX);
  ecma_char_t first = ecma_string_get_char_at_pos (str_p, (lit_utf8_size_t) index);

  if (!lit_is_code_point_utf16_high_surrogate (first))
  {
    return next_index;
  }

  ecma_char_t second = ecma_string_get_char_at_pos (str_p, (lit_utf8_size_t) next_index);

  if (!lit_is_code_point_utf16_low_surrogate (second))
  {
    return next_index;
  }

  return next_index + 1;
}  