ISSUE ID:- RICAPP-216
[ric-app/bouncer.git] / Bouncer / e2sm_kpm / headers / UTF8String.h
1 /*-
2  * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
3  * Redistribution and modifications are permitted subject to BSD license.
4  */
5 #ifndef _UTF8String_H_
6 #define _UTF8String_H_
7
8 #include <OCTET_STRING.h>
9
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13
14 typedef OCTET_STRING_t UTF8String_t;    /* Implemented via OCTET STRING */
15
16 extern asn_TYPE_descriptor_t asn_DEF_UTF8String;
17 extern asn_TYPE_operation_t asn_OP_UTF8String;
18
19 asn_struct_print_f UTF8String_print;
20 asn_constr_check_f UTF8String_constraint;
21 asn_random_fill_f  UTF8String_random_fill;
22
23 #define UTF8String_free         OCTET_STRING_free
24 #define UTF8String_compare      OCTET_STRING_compare
25 #define UTF8String_constraint   UTF8String_constraint
26 #define UTF8String_decode_ber   OCTET_STRING_decode_ber
27 #define UTF8String_encode_der   OCTET_STRING_encode_der
28 #define UTF8String_decode_xer   OCTET_STRING_decode_xer_utf8
29 #define UTF8String_encode_xer   OCTET_STRING_encode_xer_utf8
30 #define UTF8String_decode_uper  OCTET_STRING_decode_uper
31 #define UTF8String_encode_uper  OCTET_STRING_encode_uper
32 #define UTF8String_decode_aper  OCTET_STRING_decode_aper
33 #define UTF8String_encode_aper  OCTET_STRING_encode_aper
34
35 /*
36  * Returns length of the given UTF-8 string in characters,
37  * or a negative error code:
38  * -1:  UTF-8 sequence truncated 
39  * -2:  Illegal UTF-8 sequence start
40  * -3:  Continuation expectation failed
41  * -4:  Not minimal length encoding
42  * -5:  Invalid arguments
43  */
44 ssize_t UTF8String_length(const UTF8String_t *st);
45
46 /*
47  * Convert the UTF-8 string into a sequence of wide characters.
48  * Returns the number of characters necessary.
49  * Returned value might be greater than dstlen.
50  * In case of conversion error, 0 is returned.
51  * 
52  * If st points to a valid UTF-8 string, calling
53  *      UTF8String_to_wcs(st, 0, 0);
54  * is equivalent to
55  *      UTF8String_length(const UTF8String_t *st);
56  */
57 size_t UTF8String_to_wcs(const UTF8String_t *st, uint32_t *dst, size_t dstlen);
58
59 #ifdef __cplusplus
60 }
61 #endif
62
63 #endif  /* _UTF8String_H_ */