From 0a633e1fa9e475e6260c35e33befc49e02f90c81 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?=
In a file
-
The following example shows how it works. We have the following
+ specification in the file
+PrimStrings DEFINITIONS AUTOMATIC TAGS ::= +BEGIN + BMP ::= BMPString +END ++ +
Encoding and decoding some strings:
+-1> {ok,Bytes1} = 'PrimStrings':encode('BMP', [{0,0,53,53},{0,0,45,56}]). -{ok,[30,4,"55-8"]} -2> 'PrimStrings':decode('BMP', list_to_binary(Bytes1)). +1> asn1ct:compile('PrimStrings', [ber]). +ok +2> {ok,Bytes1} = 'PrimStrings':encode('BMP', [{0,0,53,53},{0,0,45,56}]). +{ok,<<30,4,53,54,45,56>>} +3> 'PrimStrings':decode('BMP', Bytes1). {ok,[{0,0,53,53},{0,0,45,56}]} -3> {ok,Bytes2} = 'PrimStrings':encode('BMP', [{0,0,53,53},{0,0,0,65}]). -{ok,[30,4,[53,53,0,65]]} -4> 'PrimStrings':decode('BMP', list_to_binary(Bytes2)). +4> {ok,Bytes2} = 'PrimStrings':encode('BMP', [{0,0,53,53},{0,0,0,65}]). +{ok,<<30,4,53,53,0,65>>} +5> 'PrimStrings':decode('BMP', Bytes2). {ok,[{0,0,53,53},65]} -5> {ok,Bytes3} = 'PrimStrings':encode('BMP', "BMP string"). -{ok,[30,20,[0,66,0,77,0,80,0,32,0,115,0,116,0,114,0,105,0,110,0,103]]} -6> 'PrimStrings':decode('BMP', list_to_binary(Bytes3)). +6> {ok,Bytes3} = 'PrimStrings':encode('BMP', "BMP string"). +{ok,<<30,20,0,66,0,77,0,80,0,32,0,115,0,116,0,114,0,105,0,110,0,103>>} +7> 'PrimStrings':decode('BMP', Bytes3). {ok,"BMP string"}
The UTF8String is represented in Erlang as a list of integers, where each integer represents the unicode value of one -- cgit v1.2.3