컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
텐서플로우:: 작전:: 유니코드트랜스코드
#include <string_ops.h>
입력 텍스트를 소스 인코딩에서 대상 인코딩으로 트랜스코딩합니다.
요약
입력은 모든 형태의 문자열 텐서입니다. 출력은 트랜스코딩된 문자열을 포함하는 동일한 모양의 문자열 텐서입니다. 출력 문자열은 항상 유효한 유니코드입니다. 입력에 잘못된 인코딩 위치가 포함된 경우 errors
속성은 이를 처리하는 방법에 대한 정책을 설정합니다. 기본 오류 처리 정책을 사용하는 경우 출력에서 잘못된 형식이 replacement_char
로 대체됩니다. 오류 정책이 ignore
하는 경우 입력의 잘못된 인코딩 위치는 모두 건너뛰고 출력에 포함되지 않습니다. strict
로 설정하면 잘못된 형식으로 인해 InvalidArgument 오류가 발생합니다.
이 작업은 output_encoding = input_encoding
과 함께 사용하여 입력이 이미 원하는 인코딩에 있는 경우에도 입력에 대한 올바른 형식을 적용할 수 있습니다.
인코딩을 결정하는 데 필요한 바이트 순서 표시가 입력 앞에 붙는 경우(예: 인코딩이 UTF-16이고 BOM이 빅엔디안을 나타내는 경우) 해당 BOM은 소비되고 출력으로 내보내지지 않습니다. 입력 인코딩이 명시적인 엔디안(예: UTF-16-BE)으로 표시된 경우 BOM은 줄바꿈 없는 공백으로 해석되어 출력에 보존됩니다(UTF-8의 경우 항상 포함).
최종 결과는 입력이 명시적 엔디안으로 표시되면 트랜스코딩이 소스의 모든 코드 포인트에 충실하다는 것입니다. 명시적인 엔디안으로 표시되지 않은 경우 BOM은 문자열 자체의 일부가 아닌 메타데이터로 간주되므로 출력에 보존되지 않습니다.
인수:
- 범위: 범위 개체
- 입력: 처리할 텍스트입니다. 어떤 모양이든 가질 수 있습니다.
- input_encoding: 입력 문자열의 텍스트 인코딩입니다. 이는 ICU ucnv 알고리즘 변환기가 지원하는 인코딩 중 하나입니다. 예:
"UTF-16", "US ASCII", "UTF-8"
. - output_encoding: 출력에 사용할 유니코드 인코딩입니다.
"UTF-8", "UTF-16-BE", "UTF-32-BE"
중 하나여야 합니다. 멀티바이트 인코딩은 빅엔디안입니다.
선택적 속성( Attrs
참조):
- 오류: 입력에서 잘못된 형식이 발견된 경우 오류 처리 정책입니다. 'strict' 값을 사용하면 잘못된 입력 형식에 대해 작업에서 InvalidArgument 오류가 생성됩니다. 'replace' 값(기본값)을 사용하면 작업이 입력의 잘못된 형식을
replacement_char
코드 포인트로 대체합니다. 'ignore' 값을 사용하면 작업이 입력에서 잘못된 형식을 건너뛰고 해당 출력 문자가 생성되지 않습니다. - replacement_char:
errors='replace'
일 때 입력의 유효하지 않은 형식화 대신 사용할 대체 문자 코드 포인트입니다. 유효한 유니코드 코드 포인트를 사용할 수 있습니다. 기본값은 기본 유니코드 대체 문자가 0xFFFD 또는 U+65533입니다.)
UTF-8의 경우 ' '와 같이 1바이트로 표현 가능한 대체 문자를 전달하면 잘못된 바이트가 1바이트 대체 문자로 대체되므로 소스에 대한 문자열 정렬이 유지됩니다. UTF-16-BE 및 UTF-16-LE의 경우 1바이트 또는 2바이트 대체 문자는 소스에 대한 바이트 정렬을 유지합니다.
- replacement_control_characters: C0 제어 문자(00-1F)를
replacement_char
로 바꿀지 여부입니다. 기본값은 거짓입니다.
보고:
-
Output
: output_encoding
사용하여 인코딩된 유니코드 텍스트를 포함하는 문자열 텐서입니다.
공개 속성
공공 기능
마디
::tensorflow::Node * node() const
operator::tensorflow::Input() const
연산자::텐서플로우::출력
operator::tensorflow::Output() const
공개 정적 함수
오류
Attrs Errors(
StringPiece x
)
ControlCharacters 교체
Attrs ReplaceControlCharacters(
bool x
)
교체문자
Attrs ReplacementChar(
int64 x
)
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[null,null,["최종 업데이트: 2025-07-27(UTC)"],[],[],null,["# tensorflow::ops::UnicodeTranscode Class Reference\n\ntensorflow::ops::UnicodeTranscode\n=================================\n\n`#include \u003cstring_ops.h\u003e`\n\nTranscode the input text from a source encoding to a destination encoding.\n\nSummary\n-------\n\nThe input is a string tensor of any shape. The output is a string tensor of the same shape containing the transcoded strings. [Output](/versions/r2.1/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) strings are always valid unicode. If the input contains invalid encoding positions, the `errors` attribute sets the policy for how to deal with them. If the default error-handling policy is used, invalid formatting will be substituted in the output by the `replacement_char`. If the errors policy is to `ignore`, any invalid encoding positions in the input are skipped and not included in the output. If it set to `strict` then any invalid formatting will result in an InvalidArgument error.\n\nThis operation can be used with `output_encoding = input_encoding` to enforce correct formatting for inputs even if they are already in the desired encoding.\n\nIf the input is prefixed by a Byte Order Mark needed to determine encoding (e.g. if the encoding is UTF-16 and the BOM indicates big-endian), then that BOM will be consumed and not emitted into the output. If the input encoding is marked with an explicit endianness (e.g. UTF-16-BE), then the BOM is interpreted as a non-breaking-space and is preserved in the output (including always for UTF-8).\n\nThe end result is that if the input is marked as an explicit endianness the transcoding is faithful to all codepoints in the source. If it is not marked with an explicit endianness, the BOM is not considered part of the string itself but as metadata, and so is not preserved in the output.\n\nArguments:\n\n- scope: A [Scope](/versions/r2.1/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- input: The text to be processed. Can have any shape.\n- input_encoding: Text encoding of the input strings. This is any of the encodings supported by ICU ucnv algorithmic converters. Examples: `\"UTF-16\", \"US ASCII\", \"UTF-8\"`.\n- output_encoding: The unicode encoding to use in the output. Must be one of `\"UTF-8\", \"UTF-16-BE\", \"UTF-32-BE\"`. Multi-byte encodings will be big-endian.\n\n\u003cbr /\u003e\n\nOptional attributes (see [Attrs](/versions/r2.1/api_docs/cc/struct/tensorflow/ops/unicode-transcode/attrs#structtensorflow_1_1ops_1_1_unicode_transcode_1_1_attrs)):\n\n- errors: Error handling policy when there is invalid formatting found in the input. The value of 'strict' will cause the operation to produce a InvalidArgument error on any invalid input formatting. A value of 'replace' (the default) will cause the operation to replace any invalid formatting in the input with the `replacement_char` codepoint. A value of 'ignore' will cause the operation to skip any invalid formatting in the input and produce no corresponding output character.\n- replacement_char: The replacement character codepoint to be used in place of any invalid formatting in the input when `errors='replace'`. [Any](/versions/r2.1/api_docs/cc/class/tensorflow/ops/any#classtensorflow_1_1ops_1_1_any) valid unicode codepoint may be used. The default value is the default unicode replacement character is 0xFFFD or U+65533.)\n\n\u003cbr /\u003e\n\nNote that for UTF-8, passing a replacement character expressible in 1 byte, such as ' ', will preserve string alignment to the source since invalid bytes will be replaced with a 1-byte replacement. For UTF-16-BE and UTF-16-LE, any 1 or 2 byte replacement character will preserve byte alignment to the source.\n\n- replace_control_characters: Whether to replace the C0 control characters (00-1F) with the `replacement_char`. Default is false.\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/versions/r2.1/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output): A string tensor containing unicode text encoded using `output_encoding`.\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [UnicodeTranscode](#classtensorflow_1_1ops_1_1_unicode_transcode_1a7f5400ef43a30cade48ec26babb8d8ac)`(const ::`[tensorflow::Scope](/versions/r2.1/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.1/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` input, StringPiece input_encoding, StringPiece output_encoding)` ||\n| [UnicodeTranscode](#classtensorflow_1_1ops_1_1_unicode_transcode_1a40d3c0e8ec4a39090a41db687a75e81e)`(const ::`[tensorflow::Scope](/versions/r2.1/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.1/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` input, StringPiece input_encoding, StringPiece output_encoding, const `[UnicodeTranscode::Attrs](/versions/r2.1/api_docs/cc/struct/tensorflow/ops/unicode-transcode/attrs#structtensorflow_1_1ops_1_1_unicode_transcode_1_1_attrs)` & attrs)` ||\n\n| ### Public attributes ||\n|-----------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|\n| [operation](#classtensorflow_1_1ops_1_1_unicode_transcode_1a9121969d40f22188b5468ef3a88c7e85) | [Operation](/versions/r2.1/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [output](#classtensorflow_1_1ops_1_1_unicode_transcode_1a72ea1928a722003c6a454fb3e4d99cf8) | `::`[tensorflow::Output](/versions/r2.1/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n\n| ### Public functions ||\n|-----------------------------------------------------------------------------------------------------------------------------|------------------------|\n| [node](#classtensorflow_1_1ops_1_1_unicode_transcode_1a5bd626fd8293b9ba38989e199cb56039)`() const ` | `::tensorflow::Node *` |\n| [operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_unicode_transcode_1aa3ed5d86e608fef6fe501acc1886adc4)`() const ` | ` ` ` ` |\n| [operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_unicode_transcode_1a228a8c3c53116beb44e18691ba954e40)`() const ` | ` ` ` ` |\n\n| ### Public static functions ||\n|------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|\n| [Errors](#classtensorflow_1_1ops_1_1_unicode_transcode_1a4ec0643c5c92c98679d67690e8d6826c)`(StringPiece x)` | [Attrs](/versions/r2.1/api_docs/cc/struct/tensorflow/ops/unicode-transcode/attrs#structtensorflow_1_1ops_1_1_unicode_transcode_1_1_attrs) |\n| [ReplaceControlCharacters](#classtensorflow_1_1ops_1_1_unicode_transcode_1ac2031f1a1d602c2981d079a72e41ad8b)`(bool x)` | [Attrs](/versions/r2.1/api_docs/cc/struct/tensorflow/ops/unicode-transcode/attrs#structtensorflow_1_1ops_1_1_unicode_transcode_1_1_attrs) |\n| [ReplacementChar](#classtensorflow_1_1ops_1_1_unicode_transcode_1a006b666456f90b0903bcaea23ee678cd)`(int64 x)` | [Attrs](/versions/r2.1/api_docs/cc/struct/tensorflow/ops/unicode-transcode/attrs#structtensorflow_1_1ops_1_1_unicode_transcode_1_1_attrs) |\n\n| ### Structs ||\n|----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [tensorflow::ops::UnicodeTranscode::Attrs](/versions/r2.1/api_docs/cc/struct/tensorflow/ops/unicode-transcode/attrs) | Optional attribute setters for [UnicodeTranscode](/versions/r2.1/api_docs/cc/class/tensorflow/ops/unicode-transcode#classtensorflow_1_1ops_1_1_unicode_transcode). |\n\nPublic attributes\n-----------------\n\n### operation\n\n```text\nOperation operation\n``` \n\n### output\n\n```text\n::tensorflow::Output output\n``` \n\nPublic functions\n----------------\n\n### UnicodeTranscode\n\n```gdscript\n UnicodeTranscode(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input,\n StringPiece input_encoding,\n StringPiece output_encoding\n)\n``` \n\n### UnicodeTranscode\n\n```gdscript\n UnicodeTranscode(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input,\n StringPiece input_encoding,\n StringPiece output_encoding,\n const UnicodeTranscode::Attrs & attrs\n)\n``` \n\n### node\n\n```gdscript\n::tensorflow::Node * node() const \n``` \n\n### operator::tensorflow::Input\n\n```gdscript\n operator::tensorflow::Input() const \n``` \n\n### operator::tensorflow::Output\n\n```gdscript\n operator::tensorflow::Output() const \n``` \n\nPublic static functions\n-----------------------\n\n### Errors\n\n```text\nAttrs Errors(\n StringPiece x\n)\n``` \n\n### ReplaceControlCharacters\n\n```text\nAttrs ReplaceControlCharacters(\n bool x\n)\n``` \n\n### ReplacementChar\n\n```text\nAttrs ReplacementChar(\n int64 x\n)\n```"]]