r"""Decodes each string in `input` into a sequence of Unicode code points. `result[i1...iN, j]` is the Unicode codepoint for the `j`th character in `input[i1...iN]`, when decoded using `input_encoding`. Args: input: An `N` dimensional potentially ragged `string` tensor with shape `
(input,
input_encoding,
errors="replace",
replacement_char=0xFFFD,
replace_control_characters=False,
name=None)
| 178 | # pylint: disable=redefined-builtin |
| 179 | @tf_export("strings.unicode_decode") |
| 180 | def unicode_decode(input, |
| 181 | input_encoding, |
| 182 | errors="replace", |
| 183 | replacement_char=0xFFFD, |
| 184 | replace_control_characters=False, |
| 185 | name=None): |
| 186 | r"""Decodes each string in `input` into a sequence of Unicode code points. |
| 187 | |
| 188 | `result[i1...iN, j]` is the Unicode codepoint for the `j`th character in |
| 189 | `input[i1...iN]`, when decoded using `input_encoding`. |
| 190 | |
| 191 | Args: |
| 192 | input: An `N` dimensional potentially ragged `string` tensor with shape |
| 193 | `[D1...DN]`. `N` must be statically known. |
| 194 | input_encoding: String name for the unicode encoding that should be used to |
| 195 | decode each string. |
| 196 | errors: Specifies the response when an input string can't be converted |
| 197 | using the indicated encoding. One of: |
| 198 | * `'strict'`: Raise an exception for any illegal substrings. |
| 199 | * `'replace'`: Replace illegal substrings with `replacement_char`. |
| 200 | * `'ignore'`: Skip illegal substrings. |
| 201 | replacement_char: The replacement codepoint to be used in place of invalid |
| 202 | substrings in `input` when `errors='replace'`; and in place of C0 control |
| 203 | characters in `input` when `replace_control_characters=True`. |
| 204 | replace_control_characters: Whether to replace the C0 control characters |
| 205 | `(U+0000 - U+001F)` with the `replacement_char`. |
| 206 | name: A name for the operation (optional). |
| 207 | |
| 208 | Returns: |
| 209 | A `N+1` dimensional `int32` tensor with shape `[D1...DN, (num_chars)]`. |
| 210 | The returned tensor is a `tf.Tensor` if `input` is a scalar, or a |
| 211 | `tf.RaggedTensor` otherwise. |
| 212 | |
| 213 | #### Example: |
| 214 | ```python |
| 215 | >>> input = [s.encode('utf8') for s in (u'G\xf6\xf6dnight', u'\U0001f60a')] |
| 216 | >>> tf.strings.unicode_decode(input, 'UTF-8').tolist() |
| 217 | [[71, 246, 246, 100, 110, 105, 103, 104, 116], [128522]] |
| 218 | ``` |
| 219 | """ |
| 220 | with ops.name_scope(name, "UnicodeDecode", [input]): |
| 221 | return _unicode_decode(input, input_encoding, errors, replacement_char, |
| 222 | replace_control_characters, with_offsets=False) |
| 223 | |
| 224 | |
| 225 | @tf_export("strings.unicode_decode_with_offsets") |
nothing calls this directly
no test coverage detected