@@ -286,6 +286,78 @@ describe('bacstack - Services layer', function() {
286286 } ) ;
287287 } ) ;
288288
289+ it ( 'should successfully encode and decode a character-string value with UCS2 encoding' , function ( ) {
290+ var buffer = utils . getBuffer ( ) ;
291+ baServices . encodeReadPropertyAcknowledge ( buffer , { type : 8 , instance : 40000 } , 81 , 0xFFFFFFFF , [
292+ { type : 7 , value : '' , encoding : baEnum . BacnetCharacterStringEncodings . CHARACTER_UCS2 } ,
293+ { type : 7 , value : 'Test1234$äöü' , encoding : baEnum . BacnetCharacterStringEncodings . CHARACTER_UCS2 }
294+ ] ) ;
295+ var result = baServices . decodeReadPropertyAcknowledge ( buffer . buffer , 0 , buffer . offset ) ;
296+ delete result . len ;
297+ expect ( result ) . to . deep . equal ( {
298+ objectId : {
299+ type : 8 ,
300+ instance : 40000
301+ } ,
302+ property : {
303+ propertyArrayIndex : 0xFFFFFFFF ,
304+ propertyIdentifier : 81
305+ } ,
306+ valueList : [
307+ { type : 7 , value : '' , encoding : baEnum . BacnetCharacterStringEncodings . CHARACTER_UCS2 , len : 2 } ,
308+ { type : 7 , value : 'Test1234$äöü' , encoding : baEnum . BacnetCharacterStringEncodings . CHARACTER_UCS2 , len : 27 }
309+ ]
310+ } ) ;
311+ } ) ;
312+
313+ it ( 'should successfully encode and decode a character-string value with Codepage850 encoding' , function ( ) {
314+ var buffer = utils . getBuffer ( ) ;
315+ baServices . encodeReadPropertyAcknowledge ( buffer , { type : 8 , instance : 40000 } , 81 , 0xFFFFFFFF , [
316+ { type : 7 , value : '' , encoding : baEnum . BacnetCharacterStringEncodings . CHARACTER_MS_DBCS } ,
317+ { type : 7 , value : 'Test1234$äöü' , encoding : baEnum . BacnetCharacterStringEncodings . CHARACTER_MS_DBCS }
318+ ] ) ;
319+ var result = baServices . decodeReadPropertyAcknowledge ( buffer . buffer , 0 , buffer . offset ) ;
320+ delete result . len ;
321+ expect ( result ) . to . deep . equal ( {
322+ objectId : {
323+ type : 8 ,
324+ instance : 40000
325+ } ,
326+ property : {
327+ propertyArrayIndex : 0xFFFFFFFF ,
328+ propertyIdentifier : 81
329+ } ,
330+ valueList : [
331+ { type : 7 , value : '' , encoding : baEnum . BacnetCharacterStringEncodings . CHARACTER_MS_DBCS , len : 2 } ,
332+ { type : 7 , value : 'Test1234$äöü' , encoding : baEnum . BacnetCharacterStringEncodings . CHARACTER_MS_DBCS , len : 15 }
333+ ]
334+ } ) ;
335+ } ) ;
336+
337+ it ( 'should successfully encode and decode a character-string value with JISX-0208 encoding' , function ( ) {
338+ var buffer = utils . getBuffer ( ) ;
339+ baServices . encodeReadPropertyAcknowledge ( buffer , { type : 8 , instance : 40000 } , 81 , 0xFFFFFFFF , [
340+ { type : 7 , value : '' , encoding : baEnum . BacnetCharacterStringEncodings . CHARACTER_JISX_0208 } ,
341+ { type : 7 , value : 'できます' , encoding : baEnum . BacnetCharacterStringEncodings . CHARACTER_JISX_0208 }
342+ ] ) ;
343+ var result = baServices . decodeReadPropertyAcknowledge ( buffer . buffer , 0 , buffer . offset ) ;
344+ delete result . len ;
345+ expect ( result ) . to . deep . equal ( {
346+ objectId : {
347+ type : 8 ,
348+ instance : 40000
349+ } ,
350+ property : {
351+ propertyArrayIndex : 0xFFFFFFFF ,
352+ propertyIdentifier : 81
353+ } ,
354+ valueList : [
355+ { type : 7 , value : '' , encoding : baEnum . BacnetCharacterStringEncodings . CHARACTER_JISX_0208 , len : 2 } ,
356+ { type : 7 , value : 'できます' , encoding : baEnum . BacnetCharacterStringEncodings . CHARACTER_JISX_0208 , len : 11 }
357+ ]
358+ } ) ;
359+ } ) ;
360+
289361 it ( 'should successfully encode and decode a bit-string value' , function ( ) {
290362 var buffer = utils . getBuffer ( ) ;
291363 baServices . encodeReadPropertyAcknowledge ( buffer , { type : 8 , instance : 40000 } , 81 , 0xFFFFFFFF , [
0 commit comments