blob: 3bc8ea69ddd4cae087dd750b0a83280d44d0998a [file] [log] [blame]
vlmfa67ddc2004-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
vlmfa67ddc2004-06-03 03:38:44 +00008#include <OCTET_STRING.h>
9
vlm3a417582005-07-24 09:03:44 +000010#ifdef __cplusplus
11extern "C" {
12#endif
13
vlmd1579582004-09-24 21:00:50 +000014typedef OCTET_STRING_t UTF8String_t; /* Implemented via OCTET STRING */
vlmfa67ddc2004-06-03 03:38:44 +000015
vlmef6355b2004-09-29 13:26:15 +000016extern asn_TYPE_descriptor_t asn_DEF_UTF8String;
vlmfa67ddc2004-06-03 03:38:44 +000017
vlmfa67ddc2004-06-03 03:38:44 +000018asn_struct_print_f UTF8String_print;
vlm39ba4c42004-09-22 16:06:28 +000019asn_constr_check_f UTF8String_constraint;
vlmfa67ddc2004-06-03 03:38:44 +000020
vlm1e10a102004-10-02 15:55:07 +000021/*
22 * Returns length of the given UTF-8 string in characters,
23 * or a negative error code:
24 * -1: UTF-8 sequence truncated
25 * -2: Illegal UTF-8 sequence start
26 * -3: Continuation expectation failed
27 * -4: Not minimal length encoding
28 * -5: Invalid arguments
29 */
30ssize_t UTF8String_length(const UTF8String_t *st);
vlmfa67ddc2004-06-03 03:38:44 +000031
vlma29c5bb2004-10-23 11:20:06 +000032/*
33 * Convert the UTF-8 string into a sequence of wide characters.
34 * Returns the number of characters necessary.
35 * Returned value might be greater than dstlen.
36 * In case of conversion error, 0 is returned.
37 *
38 * If st points to a valid UTF-8 string, calling
39 * UTF8String_to_wcs(st, 0, 0);
40 * is equivalent to
41 * UTF8String_length(const UTF8String_t *st);
42 */
43size_t UTF8String_to_wcs(const UTF8String_t *st, uint32_t *dst, size_t dstlen);
44
vlm3a417582005-07-24 09:03:44 +000045#ifdef __cplusplus
46}
47#endif
48
vlmfa67ddc2004-06-03 03:38:44 +000049#endif /* _UTF8String_H_ */