Add an API function to calculate the UTF-8 encoded string length from Jerry string. (#1460)

JerryScript-DCO-1.0-Signed-off-by: Robert Sipka rsipka.uszeged@partner.samsung.com
This commit is contained in:
Robert Sipka
2016-12-01 10:51:23 +01:00
committed by GitHub
parent 958344ee16
commit 23cf7fd177
8 changed files with 160 additions and 11 deletions
+21
View File
@@ -1086,6 +1086,27 @@ jerry_get_string_length (const jerry_value_t value) /**< input string */
return ecma_string_get_length (ecma_get_string_from_value (value));
} /* jerry_get_string_length */
/**
* Get UTF-8 string length from Jerry string
*
* Note:
* Returns 0, if the value parameter is not a string.
*
* @return number of characters in the string
*/
jerry_length_t
jerry_get_utf8_string_length (const jerry_value_t value) /**< input string */
{
jerry_assert_api_available ();
if (!ecma_is_value_string (value))
{
return 0;
}
return ecma_string_get_utf8_length (ecma_get_string_from_value (value));
} /* jerry_get_utf8_string_length */
/**
* Copy the characters of a string into a specified buffer.
*