PageRenderTime 16ms CodeModel.GetById 11ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/char_conv.h

http://datacard.googlecode.com/
C++ Header | 35 lines | 19 code | 6 blank | 10 comment | 0 complexity | b3756d7cfd21f90aa6759d2d4e233a83 MD5 | raw file
 1/*
 2   Copyright (C) 2010 bg <bg_one@mail.ru>
 3*/
 4#ifndef CHAN_DATACARD_CHAR_CONV_H_INCLUDED
 5#define CHAN_DATACARD_CHAR_CONV_H_INCLUDED
 6
 7#include <sys/types.h>			/* ssize_t size_t */
 8#include "export.h"			/* EXPORT_DECL EXPORT_DEF */
 9
10/* encoding types of strings to/from device */
11/* for simplefy first 3 values same as in PDU DCS bits 3..2 */
12/* NOTE: order is magic see definition of recoders in char_conv.c */
13typedef enum {
14	STR_ENCODING_7BIT_HEX		= 0,	/* 7bit encoding */
15	STR_ENCODING_8BIT_HEX,			/* 8bit encoding */
16	STR_ENCODING_UCS2_HEX,			/* UCS-2 in hex like PDU */
17/* TODO: check its really 7bit input from device */
18	STR_ENCODING_7BIT,			/* 7bit ASCII  no need recode to utf-8 */
19//	STR_ENCODING_8BIT,			/* 8bit */
20//	STR_ENCODING_UCS2,			/* UCS2 */
21	STR_ENCODING_UNKNOWN,			/* still unknown */
22} str_encoding_t;
23
24typedef enum {
25	RECODE_DECODE	=	0,		/* from encoded to UTF-8 */
26	RECODE_ENCODE				/* from UTF-8 to encoded */
27} recode_direction_t;
28
29/* recode in both directions */
30EXPORT_DECL ssize_t str_recode(recode_direction_t dir, str_encoding_t encoding, const char* in, size_t in_length, char* out, size_t out_size);
31
32EXPORT_DECL int parse_hexdigit(int hex);
33EXPORT_DECL str_encoding_t get_encoding(recode_direction_t hint, const char * in, size_t in_length);
34
35#endif /* CHAN_DATACARD_CHAR_CONV_H_INCLUDED */