1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 */ 4 5 #ifndef STRING_CONVERT_H 6 #define STRING_CONVERT_H 7 8 #include "stdint.h" 9 10 #define UNICODE_TO_GBK 0x0 11 #define UNICODE_BIG_TO_GBK 0x1 12 #define UTF8_TO_GBK 0x2 13 #define GBK_TO_UNICODE 0x3 14 #define UNKNOWN_CONVERT 0xFF 15 16 /** 17 * Convert char to special encode format (GBK, UNICODE, ...) 18 * @param[in] src_char character code to be converted 19 * @param[in] type convert option: UNICODE_TO_GBK, GBK_TO_UNICODE, ... 20 * @return Converted code, 0 means conversion error 21 */ 22 uint16_t char_convert(uint16_t src_char, uint32_t type); 23 24 /** 25 * Convert string to special encode format (GBK, UNICODE, ...) 26 * @param[out] dst_str converted string 27 * @param[in] max_dst_len max dst string Length(Byte) 28 * @param[in] src_str string to be converted 29 * @param[in] src_len src string's length (Byte) 30 * @param[in] type convert option: UNICODE_TO_GBK, GBK_TO_UNICODE, ... 31 * @return Converted string length, 0 means conversion error 32 */ 33 uint32_t string_convert(uint8_t* dst_str, uint32_t max_dst_len, 34 uint8_t* src_str, uint32_t src_len, uint32_t type); 35 36 #endif/* STRING_CONVERT_H */ 37 38