/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. #include <sys/types.h> /* ssize_t size_t */
  7. #include "export.h" /* EXPORT_DECL EXPORT_DEF */
  8. /* encoding types of strings to/from device */
  9. /* for simplefy first 3 values same as in PDU DCS bits 3..2 */
  10. /* NOTE: order is magic see definition of recoders in char_conv.c */
  11. typedef enum {
  12. STR_ENCODING_7BIT_HEX = 0, /* 7bit encoding */
  13. STR_ENCODING_8BIT_HEX, /* 8bit encoding */
  14. STR_ENCODING_UCS2_HEX, /* UCS-2 in hex like PDU */
  15. /* TODO: check its really 7bit input from device */
  16. STR_ENCODING_7BIT, /* 7bit ASCII no need recode to utf-8 */
  17. // STR_ENCODING_8BIT, /* 8bit */
  18. // STR_ENCODING_UCS2, /* UCS2 */
  19. STR_ENCODING_UNKNOWN, /* still unknown */
  20. } str_encoding_t;
  21. typedef enum {
  22. RECODE_DECODE = 0, /* from encoded to UTF-8 */
  23. RECODE_ENCODE /* from UTF-8 to encoded */
  24. } recode_direction_t;
  25. /* recode in both directions */
  26. EXPORT_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);
  27. EXPORT_DECL int parse_hexdigit(int hex);
  28. EXPORT_DECL str_encoding_t get_encoding(recode_direction_t hint, const char * in, size_t in_length);
  29. #endif /* CHAN_DATACARD_CHAR_CONV_H_INCLUDED */