

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# consent\$1tcf\$1v2\$1decode 函数
<a name="consent_tcf_v2_decode"></a>

该`consent_tcf_v2_decode`函数用于解码透明度和同意框架 (TCF) v2 同意数据。它将编码后的同意字符串作为输入，并返回解码后的同意数据，其中包括有关用户隐私偏好和同意选择的信息。此功能在处理包含 TCF v2 用户意见征求信息的数据时非常有用，因为它允许您以结构化格式访问和分析同意数据。

## 语法
<a name="consent_tcf_v2_decode-syntax"></a>

```
consent_tcf_v2_decode(tcf_string)
```

## 参数
<a name="consent_tcf_v2_decode-arguments"></a>

 *tcf\$1string*   
编码后的 TCF v2 同意字符串。

## 返回值
<a name="consent_tcf_v2_decode-return-type"></a>

该`consent_tcf_v2_decode`函数返回一个字典，其中包含来自透明度和同意框架 (TCF) v2 同意字符串的已解码同意数据。

返回的字典包括以下键值对：

**核心细分市场**
+ `version`：使用的 TCF 规范版本（当前为 2）。
+ `created`：用户意见征求字符串的创建日期和时间。
+ `lastUpdated`：用户意见征求字符串上次更新的日期和时间。
+ `cmpId`：对同意字符串进行编码的同意管理平台 (CMP) 的 ID。
+ `cmpVersion`：对同意字符串进行编码的 CMP 版本。
+ `consentScreen`：CMP 用户界面中用户提供同意的屏幕的 ID。
+ `consentLanguage`: 同意信息的语言代码。
+ `vendorListVersion`：使用的供应商列表版本。
+ `tcfPolicyVersion`：用户意见征求字符串所基于的 TCF 政策版本。
+ `isServiceSpecific`：一个布尔值，表示同意是针对特定服务还是适用于所有服务。
+ `useNonStandardStacks`：表示是否使用非标准堆栈的布尔值。
+ `specialFeatureOptIns`：代表用户选择使用的特殊功能的整数列表。
+ `purposeConsent`：代表用户同意的目的的整数列表。
+ `purposesLITransparency`：代表用户提供合法利益透明度的目的的整数列表。
+ `purposeOneTreatment`：一个布尔值，表示用户是否请求了 “目的为一的处理”（也就是说，所有目的都一视同仁）。
+ `publisherCountryCode`：出版商的国家/地区代码。
+ `vendorConsent`：用户已 IDs 同意的供应商列表。
+ `vendorLegitimateInterest`：已透明地传达用户合法利益的供应商 IDs 名单。
+ `pubRestrictionEntry`：发布者限制列表。此字段包含目的 ID、限制类型和 IDs 受该目的限制的供应商列表。

**已披露的供应商细分**
+ `disclosedVendors`：代表已向用户披露的供应商的整数列表。

**出版商目的细分**
+ `pubPurposesConsent`：整数列表，代表用户已同意的发布商特定用途。
+ `pubPurposesLITransparency`：代表出版商特定目的的整数列表，用户为之提供合法利益透明度。
+ `customPurposesConsent`：代表用户同意的自定义目的的整数列表。
+ `customPurposesLITransparency`：一个整数列表，代表用户为其提供合法利益透明度的自定义目的。

这些详细的同意数据可用于了解和尊重用户在处理个人数据时的隐私偏好。

## 示例
<a name="consent_tcf_v2_decode-examples"></a>

以下示例采用单个参数，即编码后的同意字符串。它会返回一本包含解码后的同意数据的字典，包括有关用户隐私偏好、同意选择和其他元数据的信息。

```
from aws_clean_rooms.functions import consent_tcf_v2_decode

consent_string = "CO1234567890abcdef"
consent_data = consent_tcf_v2_decode(consent_string)

print(consent_data)
```

返回的同意数据的基本结构包括有关同意字符串版本、CMP（同意管理平台）详细信息、用户出于不同目的和供应商的同意和合法利益选择以及其他元数据的信息。

```
    /** core segment **/
    version: 2,
    created: "2023-10-01T12:00:00Z",
    lastUpdated: "2023-10-01T12:00:00Z",
    cmpId: 1234,
    cmpVersion: 5,
    consentScreen: 1,
    consentLanguage: "en",
    vendorListVersion: 2,
    tcfPolicyVersion: 2,
    isServiceSpecific: false,
    useNonStandardStacks: false,
    specialFeatureOptIns: [1, 2, 3],
    purposeConsent: [1, 2, 3],
    purposesLITransparency: [1, 2, 3],
    purposeOneTreatment: true,
    publisherCountryCode: "US",
    vendorConsent: [1, 2, 3],
    vendorLegitimateInterest: [1, 2, 3],
    pubRestrictionEntry: [
        { purpose: 1, restrictionType: 2, restrictionDescription: "Example restriction" },
    ],

    /** disclosed vendor segment **/
    disclosedVendors: [1, 2, 3],

    /** publisher purposes  segment **/
    pubPurposesConsent: [1, 2, 3],
    pubPurposesLITransparency: [1, 2, 3],
    customPurposesConsent: [1, 2, 3],
    customPurposesLITransparency: [1, 2, 3],
};
```