From 588deb8b9d04d496f0d2acf4435ae563ced09d03 Mon Sep 17 00:00:00 2001 From: ywcoder <1104410818@qq.com> Date: Wed, 22 Oct 2025 17:09:54 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9EFAQ=E5=90=8C=E6=BA=90?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=EF=BC=9A=E5=A6=82=E4=BD=95=E5=9C=A8URL?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E6=97=B6=E5=A4=84=E7=90=86=E7=89=B9=E6=AE=8A?= =?UTF-8?q?=E5=AD=97=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...andlingSpecialCharactersForURLEncoding.ets | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 ArkTS/entry/src/main/ets/pages/HandlingSpecialCharactersForURLEncoding.ets diff --git a/ArkTS/entry/src/main/ets/pages/HandlingSpecialCharactersForURLEncoding.ets b/ArkTS/entry/src/main/ets/pages/HandlingSpecialCharactersForURLEncoding.ets new file mode 100644 index 0000000..187e6d4 --- /dev/null +++ b/ArkTS/entry/src/main/ets/pages/HandlingSpecialCharactersForURLEncoding.ets @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* +* FAQ:如何在URL编码时处理特殊字符 + */ + +// [Start HandlingSpecialCharactersForURLEncoding] +@Entry +@Component +export struct HandlingSpecialCharactersForURLEncoding { + @State message: string = 'encode'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + .onClick(() => { + const originalString = '123+456'; + const encoded = encodeURIComponent(originalString); + console.info(encoded); // output: '123%2B456'. + }) + } + .width('100%') + } + .height('100%') + } +} + +// [End HandlingSpecialCharactersForURLEncoding] \ No newline at end of file -- Gitee From 7ca024cef2e05dba2844b8421500ab1f06f1bb70 Mon Sep 17 00:00:00 2001 From: ywcoder <1104410818@qq.com> Date: Wed, 22 Oct 2025 17:18:07 +0800 Subject: [PATCH 2/2] Copyright 2024->2025 --- .../main/ets/pages/HandlingSpecialCharactersForURLEncoding.ets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ArkTS/entry/src/main/ets/pages/HandlingSpecialCharactersForURLEncoding.ets b/ArkTS/entry/src/main/ets/pages/HandlingSpecialCharactersForURLEncoding.ets index 187e6d4..addbd95 100644 --- a/ArkTS/entry/src/main/ets/pages/HandlingSpecialCharactersForURLEncoding.ets +++ b/ArkTS/entry/src/main/ets/pages/HandlingSpecialCharactersForURLEncoding.ets @@ -1,5 +1,5 @@ /* -* Copyright (c) 2024 Huawei Device Co., Ltd. +* Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at -- Gitee