Udostępnij za pośrednictwem


Funkcja make_valid_utf8

Dotyczy: zaznacz pole wyboru oznaczone jako tak Databricks Runtime 15.4 i nowsze

Zwraca ciąg, w którym wszystkie nieprawidłowe sekwencje bajtów UTF-8 w elemencie strExprsą zastępowane znakiem zastępczym Unicode (U+FFFD).

Składnia

make_valid_utf8(strExpr)

Argumenty

  • strExprSTRING: wyrażenie.

Zwraca

Element STRINGskładający się z prawidłowej sekwencji bajtów UTF-8.

Przykłady

– Simple example taking a valid string as input.
> SELECT make_valid_utf8('Spark')
  Spark

– Simple example taking a valid collated string as input.
> SELECT make_valid_utf8('SQL' COLLATE UTF8_LCASE)
  SQL

– Simple example taking a valid hexadecimal string as input.
> SELECT make_valid_utf8(x'61')
  a

– Example taking an invalid hexadecimal string as input (illegal UTF-8 byte sequence).
> SELECT make_valid_utf8(x'80')
  �

- Example taking an invalid hexadecimal string as input (illegal UTF-8 byte sequence).
> SELECT make_valid_utf8(x'61C262')
  a�b