• Home
Name Date Size #Lines LOC

..--

AppScope/12-May-2024-3633

entry/12-May-2024-1,127999

screenshots/device/12-May-2024-

.gitignoreD12-May-2024100 77

README.mdD12-May-20241.3 KiB3618

README_zh.mdD12-May-20241.3 KiB3719

build-profile.json5D12-May-20241,019 4240

hvigorfile.tsD12-May-2024158 21

package.jsonD12-May-2024378 1818

README.md

1# String Encoding and Decoding
2
3### Introduction
4
5This sample shows how to output strings in a specified format and obtain error messages corresponding to error codes. It also demonstrates string encoding and decoding. The sample app is as follows.
6
7![](screenshots/device/image1.png)
8
9### Functions
10
111. Output in a specified format: You can use the app to output a string in different formats.
12
132. Error code parsing: You can input an error code in the app to obtain the corresponding error message.
14
153. Text encoding and decoding: You can use the app to encode and decode strings.
16
17### Required Permissions
18
19N/A
20
21### Usage
22
231. Touch **Output in specified format**. Your input is then displayed in different formats, such as integer, floating point number, and string.
24
252. Touch **Obtain error details**. The error message corresponding to the error code is displayed in the text box on each line.
26
273. Touch **Text encoder**. Your input is then encoded and displayed, together with the information about data reading and writing.
28
294. Touch **Text decoder**. The encoded text content is decoded, and the output displayed is the same as what you input.
30
31### Constraints
32
331. This sample can only be run on standard-system devices.
34
352. This sample requires DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022) to compile and run.
36

README_zh.md

1# 字符串编解码
2
3### 介绍
4
5本示例主要展示对字符串的特定格式的输出功能以及其编解码功能,通过使用[@ohos.util](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-util.md)接口提供的format和字符串编解码(TextEncoder,TextDecoder)功能,去实现对字符串特定格式的输出以及编码和解码的文本输出。
6
7特定格式输出:可以对字符串进行特定格式的输出。
8
9文本编解码:可以对字符串进行编码和解码的操作。
10
11### 效果预览
12
13![](screenshots/device/image.png)
14
15使用说明:
16
171.点击**特定格式输出**,文本框会对该字符串进行不同格式的结果输出,例如整数、浮点数、字符串等格式;
18
192.点击**文本编码器**,会对上面字符串编码,输出编码后的文本,并输出编码返回的读取与写入的信息;
20
213.点击**文本译码器**,会对第二步编码后的文本内容进行译码,输出译码后的文本。
22
23### 相关权限
24
25不涉及。
26
27### 相关依赖
28
29不涉及。
30
31### 约束与限制
32
331.本示例仅支持在标准系统上运行;
34
352.本示例仅支持API9版本SDK,版本号:3.2.9.2;
36
373.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version:3.1.0.101, built on November 29, 2022)才可编译运行。