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