1e41f4b71Sopenharmony_ci# ArkTS Subsystem Changelog 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci## cl.arkts.1 Behavior of TreeSet.clear() and TreeMap.clear() Is Changed 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci**Access Level** 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ciPublic API 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci**Reason for Change** 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ciThe constructors of the **TreeMap** and **TreeSet** classes support the input of a comparator, through which you can control the position to which an element is inserted in the binary tree. 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ciWhen the **clear** API of **TreeMap** and **TreeSet** is called, the expected result is that only data is cleared. However, the actual result is that both the data and the passed-in comparator are cleared. As a result, when the API for inserting data is called again, the rules of the default comparator, rather than those of the passed-in comparator, are used. Consequently, the result does not meet the expectation. 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci**Change Impact** 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ciThis change is a non-compatible change. It affects the sorting rule after **clear()** is called. 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci**Before Change** 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci- Case 1: When a user passes in a comparator and calls the **clear** API of **TreeMap**, the comparator becomes invalid. 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci ``` 24e41f4b71Sopenharmony_ci // Use comparator firstValue > secondValue to sort data in descending order. 25e41f4b71Sopenharmony_ci let treeMap : TreeMap<string,string> = new TreeMap<string,string>((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue}); 26e41f4b71Sopenharmony_ci treeMap.set("aa","3"); 27e41f4b71Sopenharmony_ci treeMap.set("dd","1"); 28e41f4b71Sopenharmony_ci treeMap.set("cc","2"); 29e41f4b71Sopenharmony_ci treeMap.set("bb","4"); 30e41f4b71Sopenharmony_ci let numbers = Array.from(treeMap.keys()) 31e41f4b71Sopenharmony_ci for (let item of numbers) { 32e41f4b71Sopenharmony_ci console.log("treeMap:" + item); // key: dd cc bb aa 33e41f4b71Sopenharmony_ci } 34e41f4b71Sopenharmony_ci treeMap.clear(); 35e41f4b71Sopenharmony_ci treeMap.set("aa","3"); 36e41f4b71Sopenharmony_ci treeMap.set("dd","1"); 37e41f4b71Sopenharmony_ci treeMap.set("cc","2"); 38e41f4b71Sopenharmony_ci treeMap.set("bb","4"); 39e41f4b71Sopenharmony_ci numbers = Array.from(treeMap.keys()) 40e41f4b71Sopenharmony_ci for (let item of numbers) { 41e41f4b71Sopenharmony_ci console.log("treeMap:" + item); //key: aa bb cc dd 42e41f4b71Sopenharmony_ci } 43e41f4b71Sopenharmony_ci ``` 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci- Case 2: When a user passes in a comparator and calls the **clear** API of **TreeSet**, the comparator becomes invalid. 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci ``` 48e41f4b71Sopenharmony_ci let treeSet : TreeSet<string> = new TreeSet<string>((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue}); 49e41f4b71Sopenharmony_ci treeSet.add("a"); 50e41f4b71Sopenharmony_ci treeSet.add("c"); 51e41f4b71Sopenharmony_ci treeSet.add("d"); 52e41f4b71Sopenharmony_ci treeSet.add("b"); 53e41f4b71Sopenharmony_ci let numbers = Array.from(treeSet.values()) 54e41f4b71Sopenharmony_ci for (let item of numbers) { 55e41f4b71Sopenharmony_ci console.log("TreeSet:" + item); // value: d c b a 56e41f4b71Sopenharmony_ci } 57e41f4b71Sopenharmony_ci treeSet.clear(); 58e41f4b71Sopenharmony_ci treeSet.add("a"); 59e41f4b71Sopenharmony_ci treeSet.add("c"); 60e41f4b71Sopenharmony_ci treeSet.add("d"); 61e41f4b71Sopenharmony_ci treeSet.add("b"); 62e41f4b71Sopenharmony_ci numbers = Array.from(treeSet.values()) 63e41f4b71Sopenharmony_ci for (let item of numbers) { 64e41f4b71Sopenharmony_ci console.log("TreeSet:" + item); // value: a b c d 65e41f4b71Sopenharmony_ci } 66e41f4b71Sopenharmony_ci ``` 67e41f4b71Sopenharmony_ci 68e41f4b71Sopenharmony_ci**After Change** 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_ci- Case 1: When a user passes in a comparator and calls the **clear** API of **TreeMap**, the comparator functions normally. 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci ``` 73e41f4b71Sopenharmony_ci // Use comparator firstValue > secondValue to sort data in descending order. 74e41f4b71Sopenharmony_ci let treeMap : TreeMap<string,string> = new TreeMap<string,string>((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue}); 75e41f4b71Sopenharmony_ci treeMap.set("aa","3"); 76e41f4b71Sopenharmony_ci treeMap.set("dd","1"); 77e41f4b71Sopenharmony_ci treeMap.set("cc","2"); 78e41f4b71Sopenharmony_ci treeMap.set("bb","4"); 79e41f4b71Sopenharmony_ci let numbers = Array.from(treeMap.keys()) 80e41f4b71Sopenharmony_ci for (let item of numbers) { 81e41f4b71Sopenharmony_ci console.log("treeMap:" + item); // treeMap: dd cc bb aa 82e41f4b71Sopenharmony_ci } 83e41f4b71Sopenharmony_ci treeMap.clear(); 84e41f4b71Sopenharmony_ci treeMap.set("aa","3"); 85e41f4b71Sopenharmony_ci treeMap.set("dd","1"); 86e41f4b71Sopenharmony_ci treeMap.set("cc","2"); 87e41f4b71Sopenharmony_ci treeMap.set("bb","4"); 88e41f4b71Sopenharmony_ci numbers = Array.from(treeMap.keys()) 89e41f4b71Sopenharmony_ci for (let item of numbers) { 90e41f4b71Sopenharmony_ci console.log("treeMap:" + item); // treeMap: dd cc bb aa 91e41f4b71Sopenharmony_ci } 92e41f4b71Sopenharmony_ci ``` 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ci- Case 2: When a user passes in a comparator and calls the **clear** API of **TreeSet**, the comparator functions normally. 95e41f4b71Sopenharmony_ci 96e41f4b71Sopenharmony_ci ``` 97e41f4b71Sopenharmony_ci let treeSet : TreeSet<string> = new TreeSet<string>((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue}); 98e41f4b71Sopenharmony_ci treeSet.add("a"); 99e41f4b71Sopenharmony_ci treeSet.add("c"); 100e41f4b71Sopenharmony_ci treeSet.add("d"); 101e41f4b71Sopenharmony_ci treeSet.add("b"); 102e41f4b71Sopenharmony_ci let numbers = Array.from(treeSet.values()) 103e41f4b71Sopenharmony_ci for (let item of numbers) { 104e41f4b71Sopenharmony_ci console.log("TreeSet:" + item); // TreeSet: d c b a 105e41f4b71Sopenharmony_ci } 106e41f4b71Sopenharmony_ci treeSet.clear(); 107e41f4b71Sopenharmony_ci treeSet.add("a"); 108e41f4b71Sopenharmony_ci treeSet.add("c"); 109e41f4b71Sopenharmony_ci treeSet.add("d"); 110e41f4b71Sopenharmony_ci treeSet.add("b"); 111e41f4b71Sopenharmony_ci numbers = Array.from(treeSet.values()) 112e41f4b71Sopenharmony_ci for (let item of numbers) { 113e41f4b71Sopenharmony_ci console.log("TreeSet:" + item); // TreeSet: d c b a 114e41f4b71Sopenharmony_ci } 115e41f4b71Sopenharmony_ci ``` 116e41f4b71Sopenharmony_ci 117e41f4b71Sopenharmony_ci**Start API Level** 118e41f4b71Sopenharmony_ci 119e41f4b71Sopenharmony_ci8 120e41f4b71Sopenharmony_ci 121e41f4b71Sopenharmony_ci**Change Since** 122e41f4b71Sopenharmony_ci 123e41f4b71Sopenharmony_ciOpenHarmony SDK 5.0.0.32 124e41f4b71Sopenharmony_ci 125e41f4b71Sopenharmony_ci**Key API/Component Changes** 126e41f4b71Sopenharmony_ci 127e41f4b71Sopenharmony_ciTreeMap.clear(); 128e41f4b71Sopenharmony_ci 129e41f4b71Sopenharmony_ciTreeSet.clear(); 130e41f4b71Sopenharmony_ci 131e41f4b71Sopenharmony_ci**Adaptation Guide** 132e41f4b71Sopenharmony_ci 133e41f4b71Sopenharmony_ciAfter the behavior of **TreeSet.clear()** and **TreeMap.clear()** is changed, you can sort elements without resetting the comparator. You can also reset the comparator to change the sorting mode of elements. 134e41f4b71Sopenharmony_ci 135e41f4b71Sopenharmony_ciThe reference documents are as follows: 136e41f4b71Sopenharmony_ci 137e41f4b71Sopenharmony_ci[TreeMap.clear()](../../../application-dev/reference/apis-arkts/js-apis-treemap.md#clear) 138e41f4b71Sopenharmony_ci 139e41f4b71Sopenharmony_ci[TreeSet.clear()](../../../application-dev/reference/apis-arkts/js-apis-treeset.md#clear) 140e41f4b71Sopenharmony_ci 141e41f4b71Sopenharmony_ci## cl.arkts.2 Behavior of TreeMap.setAll() Is Changed 142e41f4b71Sopenharmony_ci 143e41f4b71Sopenharmony_ci**Access Level** 144e41f4b71Sopenharmony_ci 145e41f4b71Sopenharmony_ciPublic API 146e41f4b71Sopenharmony_ci 147e41f4b71Sopenharmony_ci**Reason for Change** 148e41f4b71Sopenharmony_ci 149e41f4b71Sopenharmony_ciWhen **setAll** is called to add an empty tree map, the expected length is +0, but the actual length is +1. 150e41f4b71Sopenharmony_ci 151e41f4b71Sopenharmony_ci**Change Impact** 152e41f4b71Sopenharmony_ci 153e41f4b71Sopenharmony_ciThis change is a non-compatible change. It affects the tree map length after **TreeMap.setAll()** is called. 154e41f4b71Sopenharmony_ci 155e41f4b71Sopenharmony_ci- Before change: When treeMap1 is added using **setAll**, the tree map length is 1. 156e41f4b71Sopenharmony_ci 157e41f4b71Sopenharmony_ci ``` 158e41f4b71Sopenharmony_ci let treeMap : TreeMap<string, number> = new TreeMap(); 159e41f4b71Sopenharmony_ci let treeMap1 : TreeMap<string, number> = new TreeMap(); 160e41f4b71Sopenharmony_ci treeMap.setAll(treeMap1); // Add all elements in treeMap1 to treeMap. 161e41f4b71Sopenharmony_ci console.info("length:", treeMap.length) // length:1 162e41f4b71Sopenharmony_ci ``` 163e41f4b71Sopenharmony_ci 164e41f4b71Sopenharmony_ci- After change: When treeMap1 is added using **setAll**, the tree map length is 0. 165e41f4b71Sopenharmony_ci 166e41f4b71Sopenharmony_ci ``` 167e41f4b71Sopenharmony_ci let treeMap : TreeMap<string, number> = new TreeMap(); 168e41f4b71Sopenharmony_ci let treeMap1 : TreeMap<string, number> = new TreeMap(); 169e41f4b71Sopenharmony_ci treeMap.setAll(treeMap1); // Add all elements in treeMap1 to treeMap. 170e41f4b71Sopenharmony_ci console.info("length:",treeMap.length) // length:0 171e41f4b71Sopenharmony_ci ``` 172e41f4b71Sopenharmony_ci 173e41f4b71Sopenharmony_ci**Start API Level** 174e41f4b71Sopenharmony_ci 175e41f4b71Sopenharmony_ci8 176e41f4b71Sopenharmony_ci 177e41f4b71Sopenharmony_ci**Change Since** 178e41f4b71Sopenharmony_ci 179e41f4b71Sopenharmony_ciOpenHarmony SDK 5.0.0.32 180e41f4b71Sopenharmony_ci 181e41f4b71Sopenharmony_ci**Key API/Component Changes** 182e41f4b71Sopenharmony_ci 183e41f4b71Sopenharmony_ciTreeMap.setAll(); 184e41f4b71Sopenharmony_ci 185e41f4b71Sopenharmony_ci**Adaptation Guide** 186e41f4b71Sopenharmony_ci 187e41f4b71Sopenharmony_ciIf **TreeMap.setAll()** passes in an empty tree map, adapt to the tree map length changes. 188e41f4b71Sopenharmony_ci 189e41f4b71Sopenharmony_ciThe reference documents are as follows: 190e41f4b71Sopenharmony_ci 191e41f4b71Sopenharmony_ci[TreeMap.setAll()](../../../application-dev/reference/apis-arkts/js-apis-treemap.md#setall) 192e41f4b71Sopenharmony_ci 193e41f4b71Sopenharmony_ci## cl.arkts.3 Behavior of hasKey and has of TreeMap and TreeSet Is Changed 194e41f4b71Sopenharmony_ci 195e41f4b71Sopenharmony_ci**Access Level** 196e41f4b71Sopenharmony_ci 197e41f4b71Sopenharmony_ciPublic API 198e41f4b71Sopenharmony_ci 199e41f4b71Sopenharmony_ci**Reason for Change** 200e41f4b71Sopenharmony_ci 201e41f4b71Sopenharmony_ci1. For a **TreeMap** object with a user-defined comparator, the comparison relationship between undefined or null and other elements cannot be correctly distinguished. As a result, **hasKey(null/undefined)** returns **true** when null or undefined is not inserted. 202e41f4b71Sopenharmony_ci2. For a **TreeSet** object with a user-defined comparator, the comparison relationship between undefined or null and other elements cannot be correctly distinguished. As a result, **has(null/undefined)** returns **true** when null or undefined is not inserted. 203e41f4b71Sopenharmony_ci 204e41f4b71Sopenharmony_ci**Change Impact** 205e41f4b71Sopenharmony_ci 206e41f4b71Sopenharmony_ciThis change is a non-compatible change. It affects the return value of **TreeMap.hasKey()** and **TreeSet.has()** when undefined or null is passed in. 207e41f4b71Sopenharmony_ci 208e41f4b71Sopenharmony_ci**Before Change** 209e41f4b71Sopenharmony_ci 210e41f4b71Sopenharmony_ci- Case 1: For a **TreeMap** object with a user-defined comparator, if null or undefined is not inserted, **hasKey(null/undefined)** returns **true**. 211e41f4b71Sopenharmony_ci 212e41f4b71Sopenharmony_ci ``` 213e41f4b71Sopenharmony_ci let treeMap : TreeMap<string, number> = new TreeMap((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue}); 214e41f4b71Sopenharmony_ci treeMap.set("aa",3); 215e41f4b71Sopenharmony_ci treeMap.set("dd",1); 216e41f4b71Sopenharmony_ci let res = treeMap.hasKey(null); 217e41f4b71Sopenharmony_ci let res1 = treeMap.hasKey(undefined); 218e41f4b71Sopenharmony_ci console.info("res:", res) // res:true 219e41f4b71Sopenharmony_ci console.info("res1:",res1) // res1:true 220e41f4b71Sopenharmony_ci ``` 221e41f4b71Sopenharmony_ci 222e41f4b71Sopenharmony_ci- Case 2: For a **TreeSet** object with a user-defined comparator, if null or undefined is not inserted, **has(null/undefined)** returns **true**. 223e41f4b71Sopenharmony_ci 224e41f4b71Sopenharmony_ci ``` 225e41f4b71Sopenharmony_ci let treeSet : TreeSet<string> = new TreeSet<string>((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue}); 226e41f4b71Sopenharmony_ci treeSet.add("a"); 227e41f4b71Sopenharmony_ci treeSet.add("c"); 228e41f4b71Sopenharmony_ci let res = treeSet.has(null); 229e41f4b71Sopenharmony_ci let res1 = treeSet.has(undefined); 230e41f4b71Sopenharmony_ci console.info("res:", res) // res:true 231e41f4b71Sopenharmony_ci console.info("res1:",res1) // res1:true 232e41f4b71Sopenharmony_ci ``` 233e41f4b71Sopenharmony_ci 234e41f4b71Sopenharmony_ci**After Change** 235e41f4b71Sopenharmony_ci 236e41f4b71Sopenharmony_ci- Case 1: For a **TreeMap** object with a user-defined comparator, if null or undefined is not inserted, **hasKey(null/undefined)** returns **false**. 237e41f4b71Sopenharmony_ci 238e41f4b71Sopenharmony_ci ``` 239e41f4b71Sopenharmony_ci let treeMap : TreeMap<string, number> = new TreeMap((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue}); 240e41f4b71Sopenharmony_ci treeMap.set("aa",3); 241e41f4b71Sopenharmony_ci treeMap.set("dd",1); 242e41f4b71Sopenharmony_ci let res = treeMap.hasKey(null); 243e41f4b71Sopenharmony_ci let res1 = treeMap.hasKey(undefined); 244e41f4b71Sopenharmony_ci console.info("res:", res) // res:false 245e41f4b71Sopenharmony_ci console.info("res1:",res1) // res1:false 246e41f4b71Sopenharmony_ci ``` 247e41f4b71Sopenharmony_ci 248e41f4b71Sopenharmony_ci- Case 2: For a **TreeSet** object with a user-defined comparator, if null or undefined is not inserted, **has(null/undefined)** returns **false**. 249e41f4b71Sopenharmony_ci 250e41f4b71Sopenharmony_ci ``` 251e41f4b71Sopenharmony_ci let treeSet : TreeSet<string> = new TreeSet<string>((firstValue: string, secondValue: string) : boolean => {return firstValue > secondValue}); 252e41f4b71Sopenharmony_ci treeSet.add("a"); 253e41f4b71Sopenharmony_ci treeSet.add("c"); 254e41f4b71Sopenharmony_ci let res = treeSet.has(null); 255e41f4b71Sopenharmony_ci let res1 = treeSet.has(undefined); 256e41f4b71Sopenharmony_ci console.info("res:", res) // res:false 257e41f4b71Sopenharmony_ci console.info("res1:",res1) // res1:false 258e41f4b71Sopenharmony_ci ``` 259e41f4b71Sopenharmony_ci 260e41f4b71Sopenharmony_ci 261e41f4b71Sopenharmony_ci**Start API Level** 262e41f4b71Sopenharmony_ci 263e41f4b71Sopenharmony_ci8 264e41f4b71Sopenharmony_ci 265e41f4b71Sopenharmony_ci**Change Since** 266e41f4b71Sopenharmony_ci 267e41f4b71Sopenharmony_ciOpenHarmony SDK 5.0.0.32 268e41f4b71Sopenharmony_ci 269e41f4b71Sopenharmony_ci**Key API/Component Changes** 270e41f4b71Sopenharmony_ci 271e41f4b71Sopenharmony_ciTreeMap.hasKey(); 272e41f4b71Sopenharmony_ci 273e41f4b71Sopenharmony_ciTreeSet.has(); 274e41f4b71Sopenharmony_ci 275e41f4b71Sopenharmony_ci**Adaptation Guide** 276e41f4b71Sopenharmony_ci 277e41f4b71Sopenharmony_ciWhen null or undefined is passed in, you need to adapt to the return value changes of **TreeMap.hasKey()** and **TreeSet.has()**. 278e41f4b71Sopenharmony_ci 279e41f4b71Sopenharmony_ciThe reference documents are as follows: 280e41f4b71Sopenharmony_ci 281e41f4b71Sopenharmony_ci[TreeMap.hasKey()](../../../application-dev/reference/apis-arkts/js-apis-treemap.md#haskey) 282e41f4b71Sopenharmony_ci 283e41f4b71Sopenharmony_ci[TreeSet.has()](../../../application-dev/reference/apis-arkts/js-apis-treeset.md#has) 284e41f4b71Sopenharmony_ci 285e41f4b71Sopenharmony_ci 286e41f4b71Sopenharmony_ci## cl.arkts.4 Behavior Is Changed When the Value Added by append of the URLParams Class Contains Consecutive Spaces 287e41f4b71Sopenharmony_ci 288e41f4b71Sopenharmony_ci**Access Level** 289e41f4b71Sopenharmony_ci 290e41f4b71Sopenharmony_ciPublic API 291e41f4b71Sopenharmony_ci 292e41f4b71Sopenharmony_ci**Reason for Change** 293e41f4b71Sopenharmony_ci 294e41f4b71Sopenharmony_ciIf a string added by the **append** API of the **URLParams** class contains consecutive spaces, the consecutive spaces are incorrectly converted to only one plus sign (+). This implementation does not comply with the URL standard. 295e41f4b71Sopenharmony_ci 296e41f4b71Sopenharmony_ci **Change Impact** 297e41f4b71Sopenharmony_ci 298e41f4b71Sopenharmony_ciThis change is a non-compatible change. It affects the processing result of the **URLParams.append()** API when the input parameter contains consecutive spaces. 299e41f4b71Sopenharmony_ci 300e41f4b71Sopenharmony_ci**Start API Level** 301e41f4b71Sopenharmony_ci 302e41f4b71Sopenharmony_ci9 303e41f4b71Sopenharmony_ci 304e41f4b71Sopenharmony_ci**Change Since** 305e41f4b71Sopenharmony_ci 306e41f4b71Sopenharmony_ciOpenHarmony SDK 5.0.0.32 307e41f4b71Sopenharmony_ci 308e41f4b71Sopenharmony_ci**Key API/Component Changes** 309e41f4b71Sopenharmony_ci 310e41f4b71Sopenharmony_ci**append** of a **URLParams** object. 311e41f4b71Sopenharmony_ci 312e41f4b71Sopenharmony_ciBefore change: When a **URLParams** object uses **append()** to add the key-value pair that contains consecutive spaces, the API converts the consecutive spaces to only one plus sign (+). 313e41f4b71Sopenharmony_ci```ts 314e41f4b71Sopenharmony_ci{ 315e41f4b71Sopenharmony_ci const objectParams = new url.URLParams("key=abc") 316e41f4b71Sopenharmony_ci console.log(objectParams.toString()) // "key=abc" 317e41f4b71Sopenharmony_ci objectParams.append('key1', 'd e f'); 318e41f4b71Sopenharmony_ci console.log(objectParams.toString()) // "key=abc&key1=d+e+f" 319e41f4b71Sopenharmony_ci} 320e41f4b71Sopenharmony_ci``` 321e41f4b71Sopenharmony_ci 322e41f4b71Sopenharmony_ciAfter change: When a **URLParams** object uses **append()** to add the key-value pair that contains multiple consecutive spaces, the API converts the consecutive spaces to the corresponding number of plus signs (+). 323e41f4b71Sopenharmony_ci```ts 324e41f4b71Sopenharmony_ci{ 325e41f4b71Sopenharmony_ci const objectParams = new url.URLParams("key=abc") 326e41f4b71Sopenharmony_ci console.log(objectParams.toString()) // "key=abc" 327e41f4b71Sopenharmony_ci objectParams.append('key1', 'd e f'); 328e41f4b71Sopenharmony_ci console.log(objectParams.toString()) // "key=abc&key1=d+++e+++f" 329e41f4b71Sopenharmony_ci} 330e41f4b71Sopenharmony_ci``` 331e41f4b71Sopenharmony_ci 332e41f4b71Sopenharmony_ci**Adaptation Guide** 333e41f4b71Sopenharmony_ci 334e41f4b71Sopenharmony_ciIf the preceding scenario is used in your code, make adaptation to the key-value pairs added by **append** accordingly. 335e41f4b71Sopenharmony_ci 336e41f4b71Sopenharmony_ci## cl.arkts.5 Return Value of toString() of the URLParams Class Is Inconsistent When the Passed-in String Contains Both Uppercase and Lowercase Encoding Values 337e41f4b71Sopenharmony_ci 338e41f4b71Sopenharmony_ci**Access Level** 339e41f4b71Sopenharmony_ci 340e41f4b71Sopenharmony_ciPublic API 341e41f4b71Sopenharmony_ci 342e41f4b71Sopenharmony_ci**Reason for Change** 343e41f4b71Sopenharmony_ci 344e41f4b71Sopenharmony_ciFor the **URLParams** class, the return value of the **toString()** API is incorrect when the passed-in string contains of the URLParams constructor both uppercase and lowercase encoding values. Specifically, "%2B" is processed as "%2B", whereas "%2b" is incorrectly processed as "+". 345e41f4b71Sopenharmony_ci 346e41f4b71Sopenharmony_ci **Change Impact** 347e41f4b71Sopenharmony_ci 348e41f4b71Sopenharmony_ciThis change is a non-compatible change. It affects the return value of **URLParams.toString()** when the passed-in string of the URLParams constructor contains "%2b". 349e41f4b71Sopenharmony_ci 350e41f4b71Sopenharmony_ci**Start API Level** 351e41f4b71Sopenharmony_ci 352e41f4b71Sopenharmony_ci9 353e41f4b71Sopenharmony_ci 354e41f4b71Sopenharmony_ci**Change Since** 355e41f4b71Sopenharmony_ci 356e41f4b71Sopenharmony_ciOpenHarmony SDK 5.0.0.32 357e41f4b71Sopenharmony_ci 358e41f4b71Sopenharmony_ci**Key API/Component Changes** 359e41f4b71Sopenharmony_ci 360e41f4b71Sopenharmony_ci**toString** API of the URLParams class of the URL module. 361e41f4b71Sopenharmony_ci 362e41f4b71Sopenharmony_ciBefore change: During the creation of a URLParams object, if both "%2b" and "%2B" exist in the passed-in string, they are displayed as "+" and "%2B" in the return value of **toString()**, respectively. 363e41f4b71Sopenharmony_ci```ts 364e41f4b71Sopenharmony_ci{ 365e41f4b71Sopenharmony_ci const objectParams = new url.URLParams("key%2b=abc%2B") 366e41f4b71Sopenharmony_ci console.log(objectParams.toString()) // "key+=abc%2B" 367e41f4b71Sopenharmony_ci} 368e41f4b71Sopenharmony_ci``` 369e41f4b71Sopenharmony_ci 370e41f4b71Sopenharmony_ciAfter change: During the creation of a URLParams object, if both "%2b" and "%2B" exist in the passed-in string, they are displayed both as "%2B" in the return value of **toString()**. 371e41f4b71Sopenharmony_ci```ts 372e41f4b71Sopenharmony_ci{ 373e41f4b71Sopenharmony_ci const objectParams = new url.URLParams("key%2b=abc%2B") 374e41f4b71Sopenharmony_ci console.log(objectParams.toString()) // "key%2B=abc%2B" 375e41f4b71Sopenharmony_ci} 376e41f4b71Sopenharmony_ci``` 377e41f4b71Sopenharmony_ci 378e41f4b71Sopenharmony_ci**Adaptation Guide** 379e41f4b71Sopenharmony_ci 380e41f4b71Sopenharmony_ciIf the preceding scenario is used in your code, make adaptation to the return value of **toString()**. 381e41f4b71Sopenharmony_ci 382e41f4b71Sopenharmony_ci## cl.arkts.6 Behavior of append of the URLParams Class Is Changed 383e41f4b71Sopenharmony_ci 384e41f4b71Sopenharmony_ci**Access Level** 385e41f4b71Sopenharmony_ci 386e41f4b71Sopenharmony_ciPublic API 387e41f4b71Sopenharmony_ci 388e41f4b71Sopenharmony_ci**Reason for Change** 389e41f4b71Sopenharmony_ci 390e41f4b71Sopenharmony_ciWhen the **append()** API of the **URLParams** class is called, special characters in the passed-in key-value pair are incorrectly encoded. This behavior is inconsistent with the URL standard. As a result, exceptions occur when the key-value pair is added, deleted, modified, or queried. 391e41f4b71Sopenharmony_ci 392e41f4b71Sopenharmony_ci **Change Impact** 393e41f4b71Sopenharmony_ci 394e41f4b71Sopenharmony_ciThis change is a non-compatible change. If affects the processing result of the **URLParams.append()** API when the passed-in key-value pair contains special characters such as Chinese characters. 395e41f4b71Sopenharmony_ci 396e41f4b71Sopenharmony_ci**Start API Level** 397e41f4b71Sopenharmony_ci 398e41f4b71Sopenharmony_ci9 399e41f4b71Sopenharmony_ci 400e41f4b71Sopenharmony_ci**Change Since** 401e41f4b71Sopenharmony_ci 402e41f4b71Sopenharmony_ciOpenHarmony SDK 5.0.0.32 403e41f4b71Sopenharmony_ci 404e41f4b71Sopenharmony_ci**Key API/Component Changes** 405e41f4b71Sopenharmony_ci 406e41f4b71Sopenharmony_ci**append** API of the **URLParams** class. 407e41f4b71Sopenharmony_ci 408e41f4b71Sopenharmony_ciBefore change: The **append()** API of the **URLParams** class is used to add a key-value pair. When you want to use the **get**, **has**, **delete**, or **set** API with the added key to add, delete, modify, or query data, you must encode the key first. 409e41f4b71Sopenharmony_ci```ts 410e41f4b71Sopenharmony_ci{ 411e41f4b71Sopenharmony_ci const objectParams = new url.URLParams('?fod=1&bard=2') 412e41f4b71Sopenharmony_ci objectParams.append("key&大", "abc"); 413e41f4b71Sopenharmony_ci objectParams.has('key&大'); // false 414e41f4b71Sopenharmony_ci objectParams.has('%E5%A4%A7'); // true 415e41f4b71Sopenharmony_ci objectParams.get('key&大'); // undefined 416e41f4b71Sopenharmony_ci objectParams.get('%E5%A4%A7'); // abc 417e41f4b71Sopenharmony_ci} 418e41f4b71Sopenharmony_ci``` 419e41f4b71Sopenharmony_ci 420e41f4b71Sopenharmony_ciAfter change: The **append()** API of the **URLParams** class is used to add a key-value pair. You can directly use the added key to obtain the corresponding value for adding, deleting, modifying, and querying. 421e41f4b71Sopenharmony_ci```ts 422e41f4b71Sopenharmony_ci{ 423e41f4b71Sopenharmony_ci const objectParams = new url.URLParams('?fod=1&bard=2') 424e41f4b71Sopenharmony_ci objectParams.append("key&大", "abc"); 425e41f4b71Sopenharmony_ci objectParams.has('key&大'); // true 426e41f4b71Sopenharmony_ci objectParams.has('%E5%A4%A7'); // false 427e41f4b71Sopenharmony_ci objectParams.get('key&大'); // abc 428e41f4b71Sopenharmony_ci objectParams.get('%E5%A4%A7'); // undefined 429e41f4b71Sopenharmony_ci} 430e41f4b71Sopenharmony_ci``` 431e41f4b71Sopenharmony_ci 432e41f4b71Sopenharmony_ci**Adaptation Guide** 433e41f4b71Sopenharmony_ci 434e41f4b71Sopenharmony_ciIf the passed-in parameter of **URLParams.append()** contains special characters such as Chinese characters, you need to adapt to the changes in the processing result and return value of **has()**, **get()**, **delete()**, and **set()**. 435e41f4b71Sopenharmony_ci 436e41f4b71Sopenharmony_ci <!--no_check-->