1e41f4b71Sopenharmony_ci# ArkTS Subsystem Changelog
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci## cl.arkts.1 convertXml Now Supports parentKey
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci**Access Level**
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ciPublic API
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci**Reason for Change**
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ciThe convertXml module does not support the **parentKey** attribute. The generated object does not contain the **parentKey** attribute value.
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci**Change Impact**
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ciThis change is a non-compatible change.
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ciBefore change:
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ciWhen **convertToJSObject** parses the input parameters of an XML string, the **parentKey** attribute value cannot be correctly set.
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ciAfter change:
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ciWhen **convertToJSObject** parses the input parameters of an XML string, the **parentKey** attribute value can be correctly set.
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci**Start API Level**
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci9
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci**Change Since**
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ciOpenHarmony SDK 5.0.1.1
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci**Key API/Component Changes**
34e41f4b71Sopenharmony_ciAPI in the convertXML module:
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ciconvertToJSObject(xml: string, options?: ConvertOptions): Object;
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci**Adaptation Guide**
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ciNo adaptation is required.
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci```ts
43e41f4b71Sopenharmony_ciimport { convertxml } from '@kit.ArkTS';
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_cilet xml =
46e41f4b71Sopenharmony_ci  '<?xml version="1.0" encoding="utf-8"?>' +
47e41f4b71Sopenharmony_ci    '<note importance="high" logged="true">' +
48e41f4b71Sopenharmony_ci    '    <title>Happy</title>' +
49e41f4b71Sopenharmony_ci    '    <todo>Work</todo>' +
50e41f4b71Sopenharmony_ci    '    <todo>Play</todo>' +
51e41f4b71Sopenharmony_ci    '</note>';
52e41f4b71Sopenharmony_cilet conv = new convertxml.ConvertXML()
53e41f4b71Sopenharmony_cilet options: convertxml.ConvertOptions = {
54e41f4b71Sopenharmony_ci  trim: false,
55e41f4b71Sopenharmony_ci  declarationKey: "_declaration",
56e41f4b71Sopenharmony_ci  instructionKey: "_instruction",
57e41f4b71Sopenharmony_ci  attributesKey: "_attributes",
58e41f4b71Sopenharmony_ci  textKey: "_text",
59e41f4b71Sopenharmony_ci  cdataKey: "_cdata",
60e41f4b71Sopenharmony_ci  doctypeKey: "_doctype",
61e41f4b71Sopenharmony_ci  commentKey: "_comment",
62e41f4b71Sopenharmony_ci  parentKey: "_parent",
63e41f4b71Sopenharmony_ci  typeKey: "_type",
64e41f4b71Sopenharmony_ci  nameKey: "_name",
65e41f4b71Sopenharmony_ci  elementsKey: "_elements"
66e41f4b71Sopenharmony_ci}
67e41f4b71Sopenharmony_cilet result: ESObject = conv.convertToJSObject(xml, options);
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci// Before the change, the value of result is {"_declaration":{"_attributes":{"version":"1.0","encoding":"utf-8"}},"_elements":[{"_type":"element","_name":"note","_attributes":{"importance":"high","logged":"true"},"_elements":[{"_type":"element","_name":"title","_elements":[{"_type":"text","_text":"Happy"}]},{"_type":"element","_name":"todo","_elements":[{"_type":"text","_text":"Work"}]},{"_type":"element","_name":"todo","_elements":[{"_type":"text","_text":"Play"}]}]}]}.
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ci// After the change, the value of result is {"_declaration":{"_attributes":{"version":"1.0","encoding":"utf-8"}},"_elements":[{"_type":"element","_name":"note","_attributes":{"importance":"high","logged":"true"},"_elements":[{"_type":"element","_name":"title","_parent":"note","_elements":[{"_type":"text","_text":"Happy"}]},{"_type":"element","_name":"todo","_parent":"note","_elements":[{"_type":"text","_text":"Work"}]},{"_type":"element","_name":"todo","_parent":"note","_elements":[{"_type":"text","_text":"Play"}]}]}]}. (The parentKey attribute value is added.)
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci// This does not affect the API usage.
74e41f4b71Sopenharmony_ci// Obtain the parentKey attribute of the title tag: result1["_elements"][0]["_elements"][0]._parent
75e41f4b71Sopenharmony_ci// Obtain the nameKey attribute of the title tag: result1["_elements"][0]["_elements"][0]._name
76e41f4b71Sopenharmony_ci```
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ci## cl.arkts.2 Encoding Behavior of utf-16le and utf-16be of the util.TextEncoder Module Changed
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci**Access Level**
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ciPublic API
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci**Reason for Change**
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ciWhen TextEncoder uses the utf-16le or utf-16be encoding format, the encoded data obtained is incorrect.
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ciThe utf-16le encoding format uses little-endian. However, the encoded data is in big-endian format.
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ciThe utf-16be encoding format uses big-endian. However, the encoded data is in little-endian format.
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ciThe data obtained does not comply with the standard definition. This problem needs to be corrected.
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci**Change Impact**
95e41f4b71Sopenharmony_ci
96e41f4b71Sopenharmony_ciThis change is a non-compatible change.
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ciBefore change:
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci- The utf-16le encoding format uses little-endian. However, the encoded data is in big-endian format.
101e41f4b71Sopenharmony_ci- The utf-16be encoding format uses big-endian. However, the encoded data is in little-endian format.
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ciAfter change:
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ci- The utf-16le encoding format uses little-endian, and the encoded data is in little-endian format.
106e41f4b71Sopenharmony_ci- The utf-16be encoding format uses big-endian, and the encoded data is in big-endian format.
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ci**Start API Level**
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci9
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ci**Change Since**
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ciOpenHarmony SDK 5.0.1.1
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci**Key API/Component Changes**
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ciAPIs of the util.TextEncoder module:
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ciencodeInto(input?: string): Uint8Array;
121e41f4b71Sopenharmony_ciencodeIntoUint8Array(input: string, dest: Uint8Array): EncodeIntoUint8ArrayInfo;
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ci**Adaptation Guide**
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ciNo adaptation is required.
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ciBehavior of **encodeInto**:
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci```ts
130e41f4b71Sopenharmony_ciimport { util } from '@kit.ArkTS';
131e41f4b71Sopenharmony_ci
132e41f4b71Sopenharmony_cilet encoderUtf16Le = new util.TextEncoder("utf-16le");
133e41f4b71Sopenharmony_cilet encoderUtf16Be = new util.TextEncoder("utf-16be");
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ci// Before change:
136e41f4b71Sopenharmony_ci// let u8_le = encoderUtf16Le.encodeInto('abcdefg'); // u8_le: 0,97,0,98,0,99,0,100,0,101,0,102,0,103
137e41f4b71Sopenharmony_ci// let u8_be = encoderUtf16Be.encodeInto('abcdefg'); // u8_be: 97,0,98,0,99,0,100,0,101,0,102,0,103,0
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ci
140e41f4b71Sopenharmony_ci// After change:
141e41f4b71Sopenharmony_cilet u8_le = encoderUtf16Le.encodeInto('abcdefg'); // u8_le: 97,0,98,0,99,0,100,0,101,0,102,0,103,0
142e41f4b71Sopenharmony_cilet u8_be = encoderUtf16Be.encodeInto('abcdefg'); // u8_be: 0,97,0,98,0,99,0,100,0,101,0,102,0,103
143e41f4b71Sopenharmony_ci```
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ciBehavior of **encodeIntoUint8Array**:
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci```ts
148e41f4b71Sopenharmony_ciimport { util } from '@kit.ArkTS';
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_cilet encoderUtf16Le = new util.TextEncoder("utf-16le");
151e41f4b71Sopenharmony_cilet encoderUtf16Be = new util.TextEncoder("utf-16be");
152e41f4b71Sopenharmony_ci
153e41f4b71Sopenharmony_ci// Before change:
154e41f4b71Sopenharmony_ci// let dest_le = new Uint8Array(14);
155e41f4b71Sopenharmony_ci// let dest_be = new Uint8Array(14);
156e41f4b71Sopenharmony_ci// let res_le = encoderUtf16Le.encodeIntoUint8Array('abcdefg', dest_le); // dest_le: 0,97,0,98,0,99,0,100,0,101,0,102,0,103
157e41f4b71Sopenharmony_ci// let res_be = encoderUtf16Be.encodeIntoUint8Array('abcdefg', dest_be); // dest_be: 97,0,98,0,99,0,100,0,101,0,102,0,103,0
158e41f4b71Sopenharmony_ci
159e41f4b71Sopenharmony_ci// After change:
160e41f4b71Sopenharmony_cilet dest_le = new Uint8Array(14);
161e41f4b71Sopenharmony_cilet dest_be = new Uint8Array(14);
162e41f4b71Sopenharmony_cilet res_le = encoderUtf16Le.encodeIntoUint8Array('abcdefg', dest_le); // dest_le: 97,0,98,0,99,0,100,0,101,0,102,0,103,0
163e41f4b71Sopenharmony_cilet res_be = encoderUtf16Be.encodeIntoUint8Array('abcdefg', dest_be); // dest_be: 0,97,0,98,0,99,0,100,0,101,0,102,0,103
164e41f4b71Sopenharmony_ci```
165