From 6e8923c8712ce9875863408d3bd695375d8e8973 Mon Sep 17 00:00:00 2001
From: luoqing <luoqing@kylinsec.com.cn>
Date: Tue, 29 Aug 2023 15:21:50 +0800
Subject: [PATCH 2/2] fix(audio):Fix parsing error when json contains Chinese
 characters
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

- 修复json中包含中文字符时的解析错误

Related #13261
---
 plugins/audio/src/plugin/input-page.cpp  | 2 +-
 plugins/audio/src/plugin/output-page.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/plugins/audio/src/plugin/input-page.cpp b/plugins/audio/src/plugin/input-page.cpp
index 00826b4..8b0ecaa 100644
--- a/plugins/audio/src/plugin/input-page.cpp
+++ b/plugins/audio/src/plugin/input-page.cpp
@@ -202,7 +202,7 @@ void InputPage::initActivedPort()
     KLOG_DEBUG() << "getPorts:" << getPorts;
     //解析默认source的端口信息
     QJsonParseError jsonParseError;
-    QJsonDocument doc = QJsonDocument::fromJson(getPorts.value().toLatin1(), &jsonParseError);
+    QJsonDocument doc = QJsonDocument::fromJson(getPorts.value().toUtf8(), &jsonParseError);
     if (!doc.isNull() && jsonParseError.error == QJsonParseError::NoError)
     {
         if (doc.isArray() && jsonParseError.error == QJsonParseError::NoError)
diff --git a/plugins/audio/src/plugin/output-page.cpp b/plugins/audio/src/plugin/output-page.cpp
index ef52165..420cf98 100644
--- a/plugins/audio/src/plugin/output-page.cpp
+++ b/plugins/audio/src/plugin/output-page.cpp
@@ -98,7 +98,7 @@ void OutputPage::initActivedPort()
 
     //解析默认sink的端口信息
     QJsonParseError jsonParseError;
-    QJsonDocument doc = QJsonDocument::fromJson(getPorts.value().toLatin1(), &jsonParseError);
+    QJsonDocument doc = QJsonDocument::fromJson(getPorts.value().toUtf8(), &jsonParseError);
     if (!doc.isNull() && jsonParseError.error == QJsonParseError::NoError)
     {
         if (doc.isArray() && jsonParseError.error == QJsonParseError::NoError)
-- 
2.33.0

