make_valid_utf8 函数

适用于:勾选“是” Databricks Runtime 15.4 及更高版本

返回一个字符串,其中 strExpr 中的所有无效 UTF-8 字节序列均被 Unicode 替换字符 (U+FFFD) 替换。

语法

make_valid_utf8(strExpr)

参数

  • strExpr:一个 STRING 表达式。

返回

STRING,由有效的 UTF-8 字节序列组成。

示例

– 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