Skip to main content


1. UTF8TOSTRING Function

The UTF8TOSTRING function in H2 database is used to convert a UTF-8 encoded string to a Java String.

2. Syntax

The syntax for the UTF8TOSTRING function in H2 database is as follows:



  • utf8: The UTF-8 encoded string that needs to be converted to a Java String. It should be a binary value.


  • The UTF8TOSTRING function returns the corresponding Java String representation of the UTF-8 encoded input.

3. Notes

  • The UTF8TOSTRING function in H2 database is primarily used for converting binary data that represents UTF-8 encoded strings to human-readable strings.
  • If the input binary value is not a valid UTF-8 encoded string, the function may return unexpected results or throw an error.
  • Ensure that the input value is a binary value representing a valid UTF-8 encoded string to get accurate results.

4. Examples

Here are a few examples demonstrating the usage of the UTF8TOSTRING function in H2 database:

Example 1 - Converting a UTF-8 encoded string to Java String:

SELECT UTF8TOSTRING(X'48656C6C6F20576F726C64') AS result;


Hello World

Example 2 - Converting a column of UTF-8 encoded strings to Java Strings:

CREATE TABLE encoded_strings (
utf8_value BINARY

INSERT INTO encoded_strings VALUES (1, X'48656C6C6F'), (2, X'576F726C64'), (3, X'48616C6C6F');

SELECT id, utf8_value, UTF8TOSTRING(utf8_value) AS result
FROM encoded_strings;


id | utf8_value     | result
1 | 48656C6C6F | Hello
2 | 576F726C64 | World
3 | 48616C6C6F | Hallo