ml.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* Copyright (C) 2016 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef __ML_H__
  13. #define __ML_H__
  14. #include "osi_api.h"
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. enum
  19. {
  20. ML_ISO8859_1,
  21. ML_UTF8,
  22. ML_UTF16BE,
  23. ML_UTF16LE,
  24. ML_GSM,
  25. ML_CP936,
  26. ML_IRA
  27. };
  28. void mlInit(void);
  29. /**
  30. * convert a string charset
  31. *
  32. * When \a from_charset or \a to_charset is unknown or unsupported,
  33. * return NULL.
  34. *
  35. * The returned pointer is allocated inside, caller should free it.
  36. *
  37. * At most \a from_size byte count will be processed. When \a from_size
  38. * is -1, process till null chracter.
  39. *
  40. * null character will always be inserted into the output string.
  41. * Invalid characters are replaced silently.
  42. *
  43. * \a to_size can be NULL in case that the output byte count is not needed.
  44. *
  45. * @param from input string
  46. * @param from_size input string byte count
  47. * @param from_chset input string charset
  48. * @param to_chset output string charset
  49. * @param to_size output string byte count
  50. * @return
  51. * - NULL: invalid parameters
  52. * - output string
  53. */
  54. void *mlConvertStr(const void *from, int from_size, unsigned from_chset, unsigned to_chset, int *to_size);
  55. int mlCharCount(const void *s, unsigned chset);
  56. int mlStrBytes(const void *s, unsigned chset);
  57. uint16_t mlGetUnicode(uint16_t from, uint32_t from_chset);
  58. uint16_t mlGetOEM(uint32_t unicd, uint32_t to_chset);
  59. uint32_t mlSetLocalChset(uint32_t nChset);
  60. uint32_t mlGetLocalChset(void);
  61. #ifdef __cplusplus
  62. }
  63. #endif
  64. #endif