blob: 84e6eaff87a0bb67bd6bece2cb8dcbb902ec84a5 [file] [log] [blame]
Lev Walkinf15320b2004-06-03 03:38:44 +00001/*-
2 * Copyright (c) 2003, 2004 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
Lev Walkinf15320b2004-06-03 03:38:44 +00008#include <OCTET_STRING.h>
9
Lev Walkin11c3e172004-09-24 21:00:50 +000010typedef OCTET_STRING_t UTF8String_t; /* Implemented via OCTET STRING */
Lev Walkinf15320b2004-06-03 03:38:44 +000011
Lev Walkin5e033762004-09-29 13:26:15 +000012extern asn_TYPE_descriptor_t asn_DEF_UTF8String;
Lev Walkinf15320b2004-06-03 03:38:44 +000013
Lev Walkinf15320b2004-06-03 03:38:44 +000014asn_struct_print_f UTF8String_print;
Lev Walkina9cc46e2004-09-22 16:06:28 +000015asn_constr_check_f UTF8String_constraint;
Lev Walkinf15320b2004-06-03 03:38:44 +000016
Lev Walkinedc7d592004-10-02 15:55:07 +000017/*
18 * Returns length of the given UTF-8 string in characters,
19 * or a negative error code:
20 * -1: UTF-8 sequence truncated
21 * -2: Illegal UTF-8 sequence start
22 * -3: Continuation expectation failed
23 * -4: Not minimal length encoding
24 * -5: Invalid arguments
25 */
26ssize_t UTF8String_length(const UTF8String_t *st);
Lev Walkinf15320b2004-06-03 03:38:44 +000027
Lev Walkin9a6f65b2004-10-23 11:20:06 +000028/*
29 * Convert the UTF-8 string into a sequence of wide characters.
30 * Returns the number of characters necessary.
31 * Returned value might be greater than dstlen.
32 * In case of conversion error, 0 is returned.
33 *
34 * If st points to a valid UTF-8 string, calling
35 * UTF8String_to_wcs(st, 0, 0);
36 * is equivalent to
37 * UTF8String_length(const UTF8String_t *st);
38 */
39size_t UTF8String_to_wcs(const UTF8String_t *st, uint32_t *dst, size_t dstlen);
40
Lev Walkinf15320b2004-06-03 03:38:44 +000041#endif /* _UTF8String_H_ */