diff --git a/OpenHarmony/ohos_msgpack/.gitignore b/OpenHarmony/ohos_msgpack/.gitignore
new file mode 100644
index 0000000..fbabf77
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/.gitignore
@@ -0,0 +1,11 @@
+/node_modules
+/oh_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+**/.test
\ No newline at end of file
diff --git a/OpenHarmony/ohos_msgpack/AppScope/app.json5 b/OpenHarmony/ohos_msgpack/AppScope/app.json5
new file mode 100644
index 0000000..796e4f3
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/AppScope/app.json5
@@ -0,0 +1,10 @@
+{
+ "app": {
+ "bundleName": "cn.openharmony.msgpack",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.2-rc.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/OpenHarmony/ohos_msgpack/AppScope/resources/base/element/string.json b/OpenHarmony/ohos_msgpack/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000..40ba973
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "ohos_msgpack"
+ }
+ ]
+}
diff --git a/OpenHarmony/ohos_msgpack/AppScope/resources/base/media/app_icon.png b/OpenHarmony/ohos_msgpack/AppScope/resources/base/media/app_icon.png
new file mode 100644
index 0000000..ce307a8
Binary files /dev/null and b/OpenHarmony/ohos_msgpack/AppScope/resources/base/media/app_icon.png differ
diff --git a/OpenHarmony/ohos_msgpack/CHANGELOG.md b/OpenHarmony/ohos_msgpack/CHANGELOG.md
new file mode 100644
index 0000000..4a15092
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/CHANGELOG.md
@@ -0,0 +1,12 @@
+## 1.0.2-rc.0
+- Fix Compilation Warnings
+
+## 1.0.1
+- 发布正式版本1.0.1
+
+## 1.0.1-rc.0
+- 现以基于msgpack2.8 版本进行升级,升级成为msgpack3.0版本,可以实现更为复杂的编码。
+
+## 1.0.0-rc.0
+- 基于msgpack 原库3.0.0-beta2 版本进行适配,使其可以运行在 OpenHarmony,并沿用其现有用法和特性。
+- 提供了一种紧凑高效的二进制序列化格式。
\ No newline at end of file
diff --git a/OpenHarmony/ohos_msgpack/LICENSE b/OpenHarmony/ohos_msgpack/LICENSE
new file mode 100644
index 0000000..f0e7f3e
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/LICENSE
@@ -0,0 +1,5 @@
+Copyright 2019 The MessagePack Community.
+
+Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/OpenHarmony/ohos_msgpack/NOTICE b/OpenHarmony/ohos_msgpack/NOTICE
new file mode 100644
index 0000000..26a5915
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/NOTICE
@@ -0,0 +1,21 @@
+OPEN SOURCE SOFTWARE NOTICE
+
+Please note we provide an open source software notice for the third party open source software along with this software and/or this software component (in the following just “this SOFTWARE”). The open source software licenses are granted by the respective right holders.
+
+Warranty Disclaimer
+THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
+
+Copyright Notice and License Texts
+
+----------------------------------------------------------------------
+Software: msgpack-javascript v3.0.0-beta2
+Copyright notice:
+Copyright (c) 2019 The MessagePack Community.
+License: ISC License
+
+Copyright 2019 The MessagePack Community.
+
+Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
diff --git a/OpenHarmony/ohos_msgpack/OAT.xml b/OpenHarmony/ohos_msgpack/OAT.xml
new file mode 100644
index 0000000..a4790a8
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/OAT.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OpenHarmony/ohos_msgpack/README.OpenSource b/OpenHarmony/ohos_msgpack/README.OpenSource
new file mode 100644
index 0000000..01d20e4
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/README.OpenSource
@@ -0,0 +1,11 @@
+[
+ {
+ "Name": "msgpack-javascript",
+ "License": "ISC License",
+ "License File": " LICENSE ",
+ "Version Number": "v3.0.0-beta2",
+ "Owner": "xiafeng@huawei.com",
+ "Upstream URL": "https://github.com/msgpack/msgpack-javascript",
+ "Description": "MessagePack is an extremely efficient object serialization library. It's like JSON, but very fast and small."
+ }
+]
\ No newline at end of file
diff --git a/OpenHarmony/ohos_msgpack/README.md b/OpenHarmony/ohos_msgpack/README.md
new file mode 100644
index 0000000..0d0590a
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/README.md
@@ -0,0 +1,118 @@
+# msgpack-javascript
+
+## Introduction
+> MessagePack is a library that provides efficient object serialization. It is like JSON but offers higher efficiency and smaller data size.
+> Currently, MessagePack 3.0 can be used to implement complex int64 encoding.
+
+## How to Install
+```shell
+ohpm install @ohos/msgpack
+```
+For details, see [Installing an OpenHarmony HAR](https://gitcode.com/openharmony-tpc/docs/blob/master/OpenHarmony_har_usage.en.md).
+
+## How to Use
+
+### Encoding and Decoding
+```javascript
+import { encode,decode } from "@ohos/msgpack";
+
+// Encode.
+let encoded:Uint8Array = encode({ foo: "bar" });
+// Decode.
+let decodedObject = decode(encoded);
+```
+
+### Using Encoder and Decoder
+```javascript
+import { Encoder,Decoder } from "@ohos/msgpack";
+// Reuse the encoder instance.
+let encoder = new Encoder()
+// Reuse the decoder instance.
+let decoder = new Decoder()
+// Encode.
+let encoded:Uint8Array = encoder.encode({ foo: "bar" });
+// Decode.
+let decodedObject = decoder.decode(encoded);
+// Decode a complex int64 object.
+let data: ESObject =
+ {
+ ints: [0, Number.MAX_SAFE_INTEGER, Number.MIN_SAFE_INTEGER],
+ nums: [Number.NaN, Math.PI, Math.E, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY],
+ bigints: [BigInt(0), BigInt(Number.MAX_SAFE_INTEGER) + BigInt(1), BigInt(Number.MIN_SAFE_INTEGER) - BigInt(1)],
+ };
+// Encode the minimum int64 value.
+return BigInt(Number.MIN_SAFE_INTEGER) - BigInt(1);
+// Encode and decode a common int64 value.
+return BigInt(0);
+// Encode the maximum int64 value.
+return BigInt(Number.MAX_SAFE_INTEGER) + BigInt(1);
+```
+
+### Encoding and Decoding an Array Object
+
+```javascript
+import { encode,decodeMulti } from "@ohos/msgpack";
+
+let items = [
+ "foo",
+ 10,
+ {
+ name: "bar",
+ },
+ [1, 2, 3],
+];
+// Encode the item array.
+let encodedItems = items.map((item) => encode(item));
+// Create a blank buffer for storing streams.
+let encoded = new Uint8Array(encodedItems.reduce((p, c) => p + c.byteLength, 0));
+let offset = 0;
+// Store the encoded items in the buffer.
+for (let encodedItem of encodedItems) {
+ encoded.set(encodedItem, offset);
+ offset += encodedItem.byteLength;
+}
+let result: Array = [];
+// Store the decoded items in the result array.
+for (let item of decodeMulti(encoded)) {
+ result.push(item);
+}
+// The value of result is the same as that of items.
+expect(result).assertDeepEquals(items);
+```
+
+## Directory Structure
+````
+|---- msgpackJavaScript
+| |---- entry # Sample code
+| |---- Index.ets # External APIs
+ |---- EncodeDecodePage.ets # Common encoding and decoding
+ |---- Encoding64DemoFour.ets # Decoding complex int64 objects
+ |---- Encoding64DemoOne.ets # Encoding the minimum int64 value
+ |---- Encoding64DemoThree.ets # Encoding and decoding the common int64 value
+ |---- Encoding64DemoTwo.ets # Encoding the maximum int64 value
+ |---- EncodeDecodeConstructorPage.ets # Using encoder and decoder
+ |---- MultiDecodePage.ets # Decoding complex objects
+| |---- library # Library code
+| |---- README_EN.MD # Brief introduction of the MessagePack library
+````
+
+## About obfuscation
+- Code obfuscation, please see[Code Obfuscation](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/source-obfuscation.md)
+- If you want the msgpack-javascript library not to be obfuscated during code obfuscation, you need to add corresponding exclusion rules in the obfuscation rule configuration file obfuscation-rules.txt:
+```
+-keep
+./oh_modules/@ohos/msgpack
+```
+
+## Constraints
+
+MessagePack has been verified only in the following version:
+
+- DevEco Studio: 5.0.3.132, SDK: API12 (5.0.0.19)
+
+## How to Contribute
+
+If you find any problem during the use, submit an [Issue](https://gitcode.com/openharmony-tpc/openharmony_tpc_samples/issues) or a [PR](https://gitcode.com/openharmony-tpc/openharmony_tpc_samples) to us.
+
+## License
+This project is licensed under [ISC License](https://gitcode.com/openharmony-tpc/openharmony_tpc_samples/blob/master/ohos_msgpack/LICENSE).
diff --git a/OpenHarmony/ohos_msgpack/README_zh.md b/OpenHarmony/ohos_msgpack/README_zh.md
new file mode 100644
index 0000000..cbfc967
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/README_zh.md
@@ -0,0 +1,119 @@
+# msgpack-javascript
+
+## 简介
+> MessagePack是一个非常高效的对象序列化库。它像JSON,但速度很快,而且很小。
+> 现在MessagePack已经适配了3.0版本,可用于实现int64的复杂性编码。
+
+## 下载安装
+```shell
+ohpm install @ohos/msgpack
+```
+OpenHarmony ohpm 环境配置等更多内容,请参考[如何安装 OpenHarmony ohpm 包](https://gitcode.com/openharmony-tpc/docs/blob/master/OpenHarmony_har_usage.md)
+
+## 使用说明
+
+### 编解码
+```javascript
+import { encode,decode } from "@ohos/msgpack";
+
+// 编码
+let encoded:Uint8Array = encode({ foo: "bar" });
+// 解码
+let decodedObject = decode(encoded);
+```
+
+### 构造器编解码
+```javascript
+import { Encoder,Decoder } from "@ohos/msgpack";
+// 编码可复用构造器
+let encoder = new Encoder()
+// 解码可复用构造器
+let decoder = new Decoder()
+// 编码
+let encoded:Uint8Array = encoder.encode({ foo: "bar" });
+// 解码
+let decodedObject = decoder.decode(encoded);
+// int64复杂对象解码
+let data: ESObject =
+ {
+ ints: [0, Number.MAX_SAFE_INTEGER, Number.MIN_SAFE_INTEGER],
+ nums: [Number.NaN, Math.PI, Math.E, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY],
+ bigints: [BigInt(0), BigInt(Number.MAX_SAFE_INTEGER) + BigInt(1), BigInt(Number.MIN_SAFE_INTEGER) - BigInt(1)],
+ };
+// int64编码最小值
+return BigInt(Number.MIN_SAFE_INTEGER) - BigInt(1);
+// int64普通编解码
+return BigInt(0);
+// int64编码最大值
+return BigInt(Number.MAX_SAFE_INTEGER) + BigInt(1);
+```
+
+### 数组对象编解码
+
+```javascript
+import { encode,decodeMulti } from "@ohos/msgpack";
+
+let items = [
+ "foo",
+ 10,
+ {
+ name: "bar",
+ },
+ [1, 2, 3],
+];
+// 将数组编码
+let encodedItems = items.map((item) => encode(item));
+// 创建空白缓存区用来后续存数据流
+let encoded = new Uint8Array(encodedItems.reduce((p, c) => p + c.byteLength, 0));
+let offset = 0;
+// 空白缓存区存入数据流
+for (let encodedItem of encodedItems) {
+ encoded.set(encodedItem, offset);
+ offset += encodedItem.byteLength;
+}
+let result: Array = [];
+// 解码后将数据存入result数组中
+for (let item of decodeMulti(encoded)) {
+ result.push(item);
+}
+// result与items一致
+expect(result).assertDeepEquals(items);
+```
+
+## 目录结构
+````
+|---- msgpackJavaScript
+| |---- entry # 示例代码文件夹
+| |---- Index.ets # 对外接口介绍
+ |---- EncodeDecodePage.ets # 普通编解码
+ |---- Encoding64DemoFour.ets # int64复杂对象解码
+ |---- Encoding64DemoOne.ets # int64编码最小值
+ |---- Encoding64DemoThree.ets # int64普通编解码
+ |---- Encoding64DemoTwo.ets # int64编码最大值
+ |---- EncodeDecodeConstructorPage.ets # 通过构造器编解码
+ |---- MultiDecodePage.ets # 复杂对象解码
+| |---- library # 库代码文件夹
+| |---- README.MD # 安装使用方法
+````
+
+## 关于混淆
+- 代码混淆,请查看[代码混淆简介](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/source-obfuscation.md)
+- 如果希望msgpack-javascript库在代码混淆过程中不会被混淆,需要在混淆规则配置文件obfuscation-rules.txt中添加相应的排除规则:
+```
+-keep
+./oh_modules/@ohos/msgpack
+```
+
+## 约束与限制
+
+在下述版本验证通过:
+
+- DevEco Studio: 5.0.3.132, SDK: API12 (5.0.0.19)
+- DevEco Studio: NEXT Beta1-5.0.3.806, SDK: API12 Release (5.0.0.66)
+
+## 贡献代码
+
+使用过程中发现任何问题都可以提 [Issue](https://gitcode.com/openharmony-tpc/openharmony_tpc_samples/issues) 给组件,当然,也非常欢迎发 [PR](https://gitcode.com/openharmony-tpc/openharmony_tpc_samples) 共建。
+
+## 开源协议
+本项目基于 [ISC License](https://gitcode.com/openharmony-tpc/openharmony_tpc_samples/blob/master/ohos_msgpack/LICENSE) ,请自由地享受和参与开源。
\ No newline at end of file
diff --git a/OpenHarmony/ohos_msgpack/build-profile.json5 b/OpenHarmony/ohos_msgpack/build-profile.json5
new file mode 100644
index 0000000..f8315ec
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/build-profile.json5
@@ -0,0 +1,32 @@
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "compileSdkVersion": 12,
+ "compatibleSdkVersion": 12,
+ "name": "default",
+ "signingConfig": "default",
+ "runtimeOS": "OpenHarmony"
+ }
+ ],
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "library",
+ "srcPath": "./library"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/OpenHarmony/ohos_msgpack/entry/.gitignore b/OpenHarmony/ohos_msgpack/entry/.gitignore
new file mode 100644
index 0000000..e2713a2
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/entry/.gitignore
@@ -0,0 +1,6 @@
+/node_modules
+/oh_modules
+/.preview
+/build
+/.cxx
+/.test
\ No newline at end of file
diff --git a/OpenHarmony/ohos_msgpack/entry/build-profile.json5 b/OpenHarmony/ohos_msgpack/entry/build-profile.json5
new file mode 100644
index 0000000..dd1e4e9
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/entry/build-profile.json5
@@ -0,0 +1,29 @@
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": true,
+ "files": [
+ "./obfuscation-rules.txt"
+ // 混淆规则文件
+ ]
+ }
+ }
+ }
+ }
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/OpenHarmony/ohos_msgpack/entry/hvigorfile.ts b/OpenHarmony/ohos_msgpack/entry/hvigorfile.ts
new file mode 100644
index 0000000..c6edcd9
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/entry/hvigorfile.ts
@@ -0,0 +1,6 @@
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/OpenHarmony/ohos_msgpack/entry/obfuscation-rules.txt b/OpenHarmony/ohos_msgpack/entry/obfuscation-rules.txt
new file mode 100644
index 0000000..e900c96
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/entry/obfuscation-rules.txt
@@ -0,0 +1,26 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
+
+-keep
+./oh_modules/@ohos/msgpack
\ No newline at end of file
diff --git a/OpenHarmony/ohos_msgpack/entry/oh-package.json5 b/OpenHarmony/ohos_msgpack/entry/oh-package.json5
new file mode 100644
index 0000000..8ee8c30
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/entry/oh-package.json5
@@ -0,0 +1,12 @@
+{
+ "license": "",
+ "devDependencies": {},
+ "author": "",
+ "name": "entry",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "version": "1.0.2-rc.0",
+ "dependencies": {
+ "@ohos/msgpack": "file:../library"
+ }
+}
diff --git a/OpenHarmony/ohos_msgpack/entry/src/main/ets/entryability/EntryAbility.ts b/OpenHarmony/ohos_msgpack/entry/src/main/ets/entryability/EntryAbility.ts
new file mode 100644
index 0000000..272a4f7
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/entry/src/main/ets/entryability/EntryAbility.ts
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any purpose
+ * with or without fee is hereby granted, provided that the above copyright notice
+ * and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+import UIAbility from '@ohos.app.ability.UIAbility';
+import hilog from '@ohos.hilog';
+import window from '@ohos.window';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want, launchParam) {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy() {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage) {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err, data) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
+ });
+ }
+
+ onWindowStageDestroy() {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground() {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground() {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/EncodeDecodeConstructorPage.ets b/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/EncodeDecodeConstructorPage.ets
new file mode 100644
index 0000000..bf69fc3
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/EncodeDecodeConstructorPage.ets
@@ -0,0 +1,74 @@
+/**
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any purpose
+ * with or without fee is hereby granted, provided that the above copyright notice
+ * and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+import { encode,Encoder } from "@ohos/msgpack";
+import { decode,Decoder } from "@ohos/msgpack";
+@Entry
+@Component
+struct EncodeDecodeConstructorPage {
+
+ @State message: string = '';
+ @State message2:string = '';
+ @State message3:string = '';
+
+ encodedUint8?: Uint8Array = undefined;
+
+ build() {
+ Row() {
+ Column() {
+ Button($r('app.string.Constructor_encoding')).onClick(()=>{
+ console.log("dodo click on!")
+ let encodeletructor: Encoder = new Encoder();
+ this.encodedUint8 = encodeletructor.encode(data)
+ this.message = this.getResourceString($r('app.string.Encoded_data'))+this.encodedUint8;
+ })
+ Text(this.message)
+ .fontSize(50)
+ .fontWeight(FontWeight.Bold)
+ Button($r('app.string.constructor_to_decode')).onClick(()=>{
+ if(this.encodedUint8) {
+ let decodeletructor: Decoder = new Decoder();
+ //let decodeObj = decodeletructor.decode(this.encodedUint8)
+ this.message2 = this.getResourceString($r('app.string.Decoded_data')) + JSON.stringify(decodeletructor.decode(this.encodedUint8));
+ }else{
+ this.message3 = this.getResourceString($r('app.string.undefined'));
+ }
+ })
+ Text(this.message2)
+ .fontSize(50)
+ .fontWeight(FontWeight.Bold)
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+
+ aboutToAppear() {
+ this.message = this.getResourceString($r('app.string.Display_encoded_data'));
+ this.message2 = this.getResourceString($r('app.string.Display_decoded_data'));
+ this.message3 = this.getResourceString($r('app.string.Error_message'));
+ }
+
+ getResourceString(res: Resource) {
+ return getContext().resourceManager.getStringSync(res.id);
+ }
+}
+
+class Data{
+ foo: string = ""
+}
+
+let data: Data = { foo: "bar" }
\ No newline at end of file
diff --git a/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/EncodeDecodePage.ets b/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/EncodeDecodePage.ets
new file mode 100644
index 0000000..421d2b3
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/EncodeDecodePage.ets
@@ -0,0 +1,69 @@
+/**
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any purpose
+ * with or without fee is hereby granted, provided that the above copyright notice
+ * and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+import { encode,decode } from "@ohos/msgpack";
+@Entry
+@Component
+struct EncodeDecodePage {
+
+ @State message: string = '';
+ @State message2:string = '';
+ @State message3:string = '';
+
+ encodedUint8?: Uint8Array = undefined;
+
+ build() {
+ Row() {
+ Column() {
+ Button($r('app.string.Object_encoding')).onClick(()=>{
+ console.log("dodo click on!")
+ this.encodedUint8 = encode(data);
+ this.message = this.getResourceString($r('app.string.Encoded_data'))+this.encodedUint8;
+ })
+ Text(this.message)
+ .fontSize(50)
+ .fontWeight(FontWeight.Bold)
+ Button($r('app.string.decode')).onClick(()=>{
+ if(this.encodedUint8) {
+ this.message2 = this.getResourceString($r('app.string.Decoded_data')) + JSON.stringify(decode(this.encodedUint8));
+ }else{
+ this.message3 = this.getResourceString($r('app.string.undefined'));
+ }
+ })
+ Text(this.message2)
+ .fontSize(50)
+ .fontWeight(FontWeight.Bold)
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+ aboutToAppear() {
+ this.message = this.getResourceString($r('app.string.Display_encoded_data'));
+ this.message2 = this.getResourceString($r('app.string.Display_decoded_data'));
+ this.message3 = this.getResourceString($r('app.string.Display_decoded_data'));
+ }
+
+ getResourceString(res: Resource) {
+ return getContext().resourceManager.getStringSync(res.id);
+ }
+}
+
+class Data{
+ foo: string = ""
+}
+
+let data: Data = { foo: "bar" }
\ No newline at end of file
diff --git a/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/Encoding64DemoFour.ets b/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/Encoding64DemoFour.ets
new file mode 100644
index 0000000..80d3574
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/Encoding64DemoFour.ets
@@ -0,0 +1,102 @@
+/**
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any purpose
+ * with or without fee is hereby granted, provided that the above copyright notice
+ * and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED 'AS IS' AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+import { encode, decode, ExtensionCodec } from '@ohos/msgpack';
+
+@Entry
+@Component
+struct Encoding64DemoFour {
+ @State message: string = '';
+ @State encodedMessage: string = '';
+ @State decodeMessage: string = '';
+ encodedUint8?: Uint8Array = undefined;
+
+ aboutToAppear(): void {
+ this.message = this.getResourceString($r('app.string.Display_encoded_data'));
+ this.encodedMessage = this.getResourceString($r('app.string.Display_decoded_data'));
+ this.decodeMessage = this.getResourceString($r('app.string.Display_decoded_data'));
+ }
+
+ getResourceString(res: Resource) {
+ return getContext().resourceManager.getStringSync(res.id);
+ }
+
+ build() {
+ Row() {
+ Column() {
+ Button($r('app.string.Object_encoding')).onClick(() => {
+ const extensionCodec = new ExtensionCodec();
+ extensionCodec.register({
+ type: 0,
+ encode: (input: Object) => {
+ if (typeof input === 'bigint') {
+ if (input <= Number.MAX_SAFE_INTEGER && input >= Number.MIN_SAFE_INTEGER) {
+ return encode(Number.parseInt(input.toString(), 10));
+ } else {
+ return encode(input.toString());
+ }
+ } else {
+ return null;
+ }
+ },
+ decode: (data: Uint8Array) => {
+ const value = decode(data) as string;
+ if (!(typeof value === 'string' || typeof value === 'number')) {
+ }
+ return BigInt(value);
+ },
+ });
+
+ this.encodedUint8 = encode(data(), { useBigInt64: true,
+ extensionCodec
+ });
+ this.message = this.getResourceString($r('app.string.Encoded_data')) + this.encodedUint8;
+ })
+ Text(this.message)
+ .fontSize(25)
+ .fontWeight(FontWeight.Bold)
+ Button($r('app.string.decode')).onClick(() => {
+ if (this.encodedUint8) {
+ this.encodedMessage = this.getResourceString($r('app.string.Decoded_data')) + JSON.stringify(decode(this.encodedUint8));
+ } else {
+ this.decodeMessage = this.getResourceString($r('app.string.undefined'));
+ }
+ })
+ Text(this.encodedMessage)
+ .fontSize(25)
+ .fontWeight(FontWeight.Bold)
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+}
+
+interface CustomData {
+ ints: number[];
+ nums: number[];
+ bigints: bigint[];
+}
+
+function data() {
+ let data: CustomData =
+ {
+ ints: [0, Number.MAX_SAFE_INTEGER, Number.MIN_SAFE_INTEGER],
+ nums: [Number.NaN, Math.PI, Math.E, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY],
+ bigints: [BigInt(0), BigInt(Number.MAX_SAFE_INTEGER) + BigInt(1), BigInt(Number.MIN_SAFE_INTEGER) - BigInt(1)],
+ };
+ return data;
+}
\ No newline at end of file
diff --git a/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/Encoding64DemoOne.ets b/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/Encoding64DemoOne.ets
new file mode 100644
index 0000000..483f187
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/Encoding64DemoOne.ets
@@ -0,0 +1,90 @@
+/**
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any purpose
+ * with or without fee is hereby granted, provided that the above copyright notice
+ * and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED 'AS IS' AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+import { encode, decode, ExtensionCodec } from '@ohos/msgpack';
+
+@Entry
+@Component
+struct Encoding64DemoOne {
+ @State message: string = '';
+ @State encodedMessage: string = '';
+ @State decodeMessage: string = '';
+ encodedUint8?: Uint8Array = undefined;
+
+ aboutToAppear(): void {
+ this.message = this.getResourceString($r('app.string.Display_encoded_data'));
+ this.encodedMessage = this.getResourceString($r('app.string.Display_decoded_data'));
+ this.decodeMessage = this.getResourceString($r('app.string.Display_decoded_data'));
+ }
+
+ getResourceString(res: Resource) {
+ return getContext().resourceManager.getStringSync(res.id);
+ }
+
+ build() {
+ Row() {
+ Column() {
+ Button($r('app.string.Object_encoding')).onClick(() => {
+ const extensionCodec = new ExtensionCodec();
+ extensionCodec.register({
+ type: 0,
+ encode: (input: Object) => {
+ if (typeof input === 'bigint') {
+ if (input <= Number.MAX_SAFE_INTEGER && input >= Number.MIN_SAFE_INTEGER) {
+ return encode(Number.parseInt(input.toString(), 10));
+ } else {
+ return encode(input.toString());
+ }
+ } else {
+ return null;
+ }
+ },
+ decode: (data: Uint8Array) => {
+ const value = decode(data) as string;
+ if (!(typeof value === 'string' || typeof value === 'number')) {
+ }
+ return BigInt(value);
+ },
+ });
+
+ this.encodedUint8 = encode(data(), { useBigInt64: true,
+ extensionCodec
+ });
+ this.message = this.getResourceString($r('app.string.Encoded_data')) + this.encodedUint8;
+ })
+ Text(this.message)
+ .fontSize(25)
+ .fontWeight(FontWeight.Bold)
+ Button($r('app.string.decode')).onClick(() => {
+ if (this.encodedUint8) {
+ this.encodedMessage = this.getResourceString($r('app.string.Decoded_data')) + JSON.stringify(decode(this.encodedUint8));
+ } else {
+ this.decodeMessage = this.getResourceString($r('app.string.undefined'));
+ }
+ })
+ Text(this.encodedMessage)
+ .fontSize(25)
+ .fontWeight(FontWeight.Bold)
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+}
+
+function data() {
+ return BigInt(Number.MIN_SAFE_INTEGER) - BigInt(1);
+}
\ No newline at end of file
diff --git a/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/Encoding64DemoThree.ets b/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/Encoding64DemoThree.ets
new file mode 100644
index 0000000..4bc39fe
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/Encoding64DemoThree.ets
@@ -0,0 +1,90 @@
+/**
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any purpose
+ * with or without fee is hereby granted, provided that the above copyright notice
+ * and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED 'AS IS' AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+import { encode, decode, ExtensionCodec } from '@ohos/msgpack';
+
+@Entry
+@Component
+struct Encoding64DemoThree {
+ @State message: string = '';
+ @State encodedMessage: string = '';
+ @State decodeMessage: string = '';
+ encodedUint8?: Uint8Array = undefined;
+
+ aboutToAppear(): void {
+ this.message = this.getResourceString($r('app.string.Display_encoded_data'));
+ this.encodedMessage = this.getResourceString($r('app.string.Display_decoded_data'));
+ this.decodeMessage = this.getResourceString($r('app.string.Display_decoded_data'));
+ }
+
+ getResourceString(res: Resource) {
+ return getContext().resourceManager.getStringSync(res.id);
+ }
+
+ build() {
+ Row() {
+ Column() {
+ Button($r('app.string.Object_encoding')).onClick(() => {
+ const extensionCodec = new ExtensionCodec();
+ extensionCodec.register({
+ type: 0,
+ encode: (input: Object) => {
+ if (typeof input === 'bigint') {
+ if (input <= Number.MAX_SAFE_INTEGER && input >= Number.MIN_SAFE_INTEGER) {
+ return encode(Number.parseInt(input.toString(), 10));
+ } else {
+ return encode(input.toString());
+ }
+ } else {
+ return null;
+ }
+ },
+ decode: (data: Uint8Array) => {
+ const value = decode(data) as string;
+ if (!(typeof value === 'string' || typeof value === 'number')) {
+ }
+ return BigInt(value);
+ },
+ });
+
+ this.encodedUint8 = encode(data(), { useBigInt64: true,
+ extensionCodec
+ });
+ this.message = this.getResourceString($r('app.string.Encoded_data')) + this.encodedUint8;
+ })
+ Text(this.message)
+ .fontSize(25)
+ .fontWeight(FontWeight.Bold)
+ Button($r('app.string.decode')).onClick(() => {
+ if (this.encodedUint8) {
+ this.encodedMessage = this.getResourceString($r('app.string.Decoded_data')) + JSON.stringify(decode(this.encodedUint8));
+ } else {
+ this.decodeMessage = this.getResourceString($r('app.string.undefined'));
+ }
+ })
+ Text(this.encodedMessage)
+ .fontSize(25)
+ .fontWeight(FontWeight.Bold)
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+}
+
+function data() {
+ return BigInt(0);
+}
\ No newline at end of file
diff --git a/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/Encoding64DemoTwo.ets b/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/Encoding64DemoTwo.ets
new file mode 100644
index 0000000..47ce088
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/Encoding64DemoTwo.ets
@@ -0,0 +1,90 @@
+/**
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any purpose
+ * with or without fee is hereby granted, provided that the above copyright notice
+ * and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED 'AS IS' AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+import { encode, decode, ExtensionCodec } from '@ohos/msgpack';
+
+@Entry
+@Component
+struct Encoding64DemoTwo {
+ @State message: string = '';
+ @State encodedMessage: string = '';
+ @State decodeMessage: string = '';
+ encodedUint8?: Uint8Array = undefined;
+
+ aboutToAppear(): void {
+ this.message = this.getResourceString($r('app.string.Display_encoded_data'));
+ this.encodedMessage = this.getResourceString($r('app.string.Display_decoded_data'));
+ this.decodeMessage = this.getResourceString($r('app.string.Display_decoded_data'));
+ }
+
+ getResourceString(res: Resource) {
+ return getContext().resourceManager.getStringSync(res.id);
+ }
+
+ build() {
+ Row() {
+ Column() {
+ Button($r('app.string.Object_encoding')).onClick(() => {
+ const extensionCodec = new ExtensionCodec();
+ extensionCodec.register({
+ type: 0,
+ encode: (input: Object) => {
+ if (typeof input === 'bigint') {
+ if (input <= Number.MAX_SAFE_INTEGER && input >= Number.MIN_SAFE_INTEGER) {
+ return encode(Number.parseInt(input.toString(), 10));
+ } else {
+ return encode(input.toString());
+ }
+ } else {
+ return null;
+ }
+ },
+ decode: (data: Uint8Array) => {
+ const value = decode(data) as string;
+ if (!(typeof value === 'string' || typeof value === 'number')) {
+ }
+ return BigInt(value);
+ },
+ });
+
+ this.encodedUint8 = encode(data(), { useBigInt64: true,
+ extensionCodec
+ });
+ this.message = this.getResourceString($r('app.string.Encoded_data')) + this.encodedUint8;
+ })
+ Text(this.message)
+ .fontSize(25)
+ .fontWeight(FontWeight.Bold)
+ Button($r('app.string.decode')).onClick(() => {
+ if (this.encodedUint8) {
+ this.encodedMessage = this.getResourceString($r('app.string.Decoded_data')) + JSON.stringify(decode(this.encodedUint8));
+ } else {
+ this.decodeMessage = this.getResourceString($r('app.string.undefined'));
+ }
+ })
+ Text(this.encodedMessage)
+ .fontSize(25)
+ .fontWeight(FontWeight.Bold)
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+}
+
+function data() {
+ return BigInt(Number.MAX_SAFE_INTEGER) + BigInt(1);
+}
\ No newline at end of file
diff --git a/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/ExamPage.ets b/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/ExamPage.ets
new file mode 100644
index 0000000..93fc88b
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/ExamPage.ets
@@ -0,0 +1,133 @@
+/**
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any purpose
+ * with or without fee is hereby granted, provided that the above copyright notice
+ * and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+import { MsgTimestamp } from "../../../ohosTest/ets/test/test/msg/msg-timestamp";
+import { encode, decode, ExtensionCodec } from "@ohos/msgpack";
+import ohBuffer from '@ohos.buffer';
+import Util from './Util';
+
+@Entry
+@Component
+struct Index {
+ @State message: Resource = $r('app.string.log')
+ m1: Massage = {
+ string: "Кириллица",
+ msgpack: [
+ [0xb2, 0xd0, 0x9a, 0xd0, 0xb8, 0xd1, 0x80, 0xd0, 0xb8, 0xd0, 0xbb, 0xd0, 0xbb, 0xd0, 0xb8, 0xd1, 0x86, 0xd0, 0xb0],
+ [0xd9, 0x12, 0xd0, 0x9a, 0xd0, 0xb8, 0xd1, 0x80, 0xd0, 0xb8, 0xd0, 0xbb, 0xd0, 0xbb, 0xd0, 0xb8, 0xd1, 0x86, 0xd0, 0xb0]
+ ]
+ };
+ m2: Massage = {
+ string: "ひらがな",
+ msgpack: [
+ [0xac, 0xe3, 0x81, 0xb2, 0xe3, 0x82, 0x89, 0xe3, 0x81, 0x8c, 0xe3, 0x81, 0xaa],
+ [0xd9, 0x0c, 0xe3, 0x81, 0xb2, 0xe3, 0x82, 0x89, 0xe3, 0x81, 0x8c, 0xe3, 0x81, 0xaa]
+ ]
+ };
+ m3: Massage = {
+ string: "한글",
+ msgpack: [
+ [0xa6, 0xed, 0x95, 0x9c, 0xea, 0xb8, 0x80],
+ [0xd9, 0x06, 0xed, 0x95, 0x9c, 0xea, 0xb8, 0x80]
+ ]
+ };
+ m4: Massage = {
+ string: "汉字",
+ msgpack: [
+ [0xa6, 0xe6, 0xb1, 0x89, 0xe5, 0xad, 0x97],
+ [0xd9, 0x06, 0xe6, 0xb1, 0x89, 0xe5, 0xad, 0x97]
+ ]
+ };
+ m5: Massage = {
+ string: "漢字",
+ msgpack: [
+ [0xa6, 0xe6, 0xbc, 0xa2, 0xe5, 0xad, 0x97],
+ [0xd9, 0x06, 0xe6, 0xbc, 0xa2, 0xe5, 0xad, 0x97]
+ ]
+ };
+ m6: Massage = {
+ string: "❤",
+ msgpack: [
+ [0xa3, 0xe2, 0x9d, 0xa4],
+ [0xd9, 0x03, 0xe2, 0x9d, 0xa4]
+ ]
+ };
+ m7: Massage = {
+ string: "🍺",
+ msgpack: [
+ [0xa4, 0xf0, 0x9f, 0x8d, 0xba],
+ [0xd9, 0x04, 0xf0, 0x9f, 0x8d, 0xba]
+ ]
+ };
+
+ build() {
+ Row() {
+ Column() {
+ Button(this.message)
+ .fontSize(50)
+ .fontWeight(FontWeight.Bold)
+ .onClick(() => {
+ this.testSpecString();
+ })
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+
+ testSpecString() {
+ // 补齐XTS中未通过用例
+ let inputs = [
+ this.m1,
+ this.m2,
+ this.m3,
+ this.m4,
+ this.m5,
+ this.m6,
+ this.m7
+ ]
+
+ for (let i = 0; i < inputs.length; i++) {
+ let input = inputs[i];
+ this.checkEncodeAndDecode(input.string, input.msgpack[0], input.msgpack[1])
+ }
+
+ }
+
+ checkEncodeAndDecode(value: string, array1: number[], array2: number[]) {
+ console.log("dodo 输入value=" + value);
+ let extensionCodec: ExtensionCodec = new ExtensionCodec();
+ extensionCodec.register(Util.register);
+ let b1: Uint8Array = encode(value, { extensionCodec });
+ let u8 = b1;
+ for (let i = 0; i < u8.length; i++) {
+ console.log(`dodo 编码后buffer[${i}]=${u8[i]}`)
+ }
+ let encode1 = ohBuffer.from(array1);
+ let encode2 = ohBuffer.from(array2);
+
+ console.log("dodo 解码后 array1 对应 decode1=" + decode(encode1.buffer, {
+ extensionCodec
+ }) + " array2 对应 decode2=" + decode(encode2.buffer, { extensionCodec }));
+ }
+}
+
+class Massage {
+ string: string = "";
+ msgpack: number[][] = [[0]];
+}
\ No newline at end of file
diff --git a/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/Index.ets b/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000..5b69dd1
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,69 @@
+/**
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any purpose
+ * with or without fee is hereby granted, provided that the above copyright notice
+ * and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+import router from '@ohos.router';
+
+@Entry
+@Component
+struct Index {
+ build() {
+ Row() {
+ Column() {
+ Button($r('app.string.Simple_encoding_and_decoding'))
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/EncodeDecodePage' })
+ })
+ Button('Encoding64DemoOne')
+ .margin({ top: 10 })
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/Encoding64DemoOne' })
+ })
+ Button('Encoding64DemoTwo')
+ .margin({ top: 10 })
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/Encoding64DemoTwo' })
+ })
+ Button('Encoding64DemoThree')
+ .margin({ top: 10 })
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/Encoding64DemoThree' })
+ })
+ Button('Encoding64DemoFour')
+ .margin({ top: 10 })
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/Encoding64DemoFour' })
+ })
+ Button($r('app.string.Constructor_encoding_and_decoding'))
+ .margin({ top: 10 })
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/EncodeDecodeConstructorPage' })
+ })
+ Button($r('app.string.Complex_encoding_decoding'))
+ .margin({ top: 10 })
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/MultiDecodePage' })
+ })
+ Button($r('app.string.Special_Character'))
+ .margin({ top: 10 })
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/ExamPage' })
+ })
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+}
diff --git a/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/MultiDecodePage.ets b/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/MultiDecodePage.ets
new file mode 100644
index 0000000..1722b56
--- /dev/null
+++ b/OpenHarmony/ohos_msgpack/entry/src/main/ets/pages/MultiDecodePage.ets
@@ -0,0 +1,88 @@
+/**
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any purpose
+ * with or without fee is hereby granted, provided that the above copyright notice
+ * and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+import { encode } from "@ohos/msgpack";
+import Util from './Util';
+
+@Entry
+@Component
+struct MultiDecodePage {
+ @State message: string = '';
+ @State message2: string = '';
+ encodedUint8: Uint8Array | undefined = undefined;
+
+ aboutToAppear(): void {
+ this.message = this.getResourceString($r('app.string.Display_original_data'));
+ this.message2 = this.getResourceString($r('app.string.Data_display_after_decodeMulti_decoding'));
+ }
+
+ getResourceString(res: Resource) {
+ return getContext().resourceManager.getStringSync(res.id);
+ }
+
+ build() {
+ Row() {
+ Column() {
+ Button($r('app.string.Object_Display')).onClick(() => {
+ console.log('dodo click on!')
+ let bar: Bar = {
+ name: "bar",
+ }
+ this.message = JSON.stringify([
+ "foo",
+ 10,
+ bar,
+ [1, 2, 3],
+ ])
+ })
+ Text(this.message)
+ .fontSize(50)
+ .fontWeight(FontWeight.Bold)
+ Button($r("app.string.MultiDecoder")).onClick(() => {
+ let bar: Bar = {
+ name: "bar",
+ }
+ let items = [
+ "foo",
+ 10,
+ bar,
+ [1, 2, 3],
+ ]
+ let encodedItems: Uint8Array[] = items.map((item): Uint8Array => encode(item));
+ let encoded = new Uint8Array(encodedItems.reduce((p: number, c: Uint8Array) => p + c.byteLength, 0));
+ let offset = 0;
+ for (let encodedItem of encodedItems) {
+ encoded.set(encodedItem, offset);
+ offset += encodedItem.byteLength;
+ }
+ let result: Array