58 lines
2.8 KiB
C
58 lines
2.8 KiB
C
/*****************************************************************************
|
||
* @copyright 2024-202, . POWER SUPPLY CO., LTD.
|
||
* @file xxx.c
|
||
* @brief xxxx
|
||
* @author xx
|
||
* @date 2024/08/30
|
||
* @remark 初修订
|
||
*****************************************************************************/
|
||
|
||
#ifndef __KIT_STRING_H__
|
||
#define __KIT_STRING_H__
|
||
|
||
#include <stdio.h>
|
||
#include <stdbool.h>
|
||
#include <string.h>
|
||
#include <stdint.h>
|
||
#include <stdlib.h>
|
||
#include <unistd.h>
|
||
|
||
/*****************************************************************************
|
||
* @brief 将字符串转换为整数。如果字符串为空或为 NULL,则返回 0。
|
||
* @param[in] str: 需要转换的字符串。
|
||
* @return 转换后的整数值。如果字符串无效(NULL 或长度为 0),返回 0。
|
||
*****************************************************************************/
|
||
int kit_atoi(char *str);
|
||
|
||
/*****************************************************************************
|
||
* @brief 去除字符串右侧的无效字符(空格、回车、换行符、制表符)。
|
||
* @param[in] str: 需要处理的字符串,操作将直接修改输入的字符串。
|
||
* @return 无返回值,输入字符串将被修改。
|
||
*****************************************************************************/
|
||
void kit_trim_right(char *str);
|
||
|
||
/*****************************************************************************
|
||
* @brief 去除字符串左侧的无效字符(空格、回车、换行符、制表符)。
|
||
* @param[in] str: 需要处理的字符串,操作将直接修改输入的字符串。
|
||
* @return 无返回值,输入字符串将被修改。
|
||
*****************************************************************************/
|
||
void kit_trim_left(char *str);
|
||
|
||
/*****************************************************************************
|
||
* @brief 去除字符串两端的无效字符(空格、回车、换行符、制表符)。
|
||
* @param[in] str: 需要处理的字符串,操作将直接修改输入的字符串。
|
||
* @return 无返回值,输入字符串将被修改。
|
||
*****************************************************************************/
|
||
void kit_trim_sides(char *str);
|
||
|
||
/*****************************************************************************
|
||
* @brief 用于将字符数组拼接成一个字符串,separator分隔
|
||
* @param[in] count:字符数组数量
|
||
* @param[in] texts:字符串数组
|
||
* @param[in] separator:分隔字符
|
||
* @return 拼接起来的字符串
|
||
*****************************************************************************/
|
||
char* kit_join_text(int count, const char** texts, const char* separator);
|
||
|
||
#endif
|