Files
PathEditor/include/utils/string_ext.h
T
Serendipity cf19a37a97 feat(test): 添加单元测试框架并完善国际化支持
- 新增 CMake 测试框架配置,支持 safe_string、string_ext 和 path_manager 模块的单元测试
- 实现 Windows API Mock 机制,便于测试编码转换函数
- 添加 error_code 模块的字符串表示函数,支持英文错误日志
- 在 UI 回调函数中集成国际化翻译,覆盖新建、编辑、导入导出等操作提示
- 扩展 string_list 功能,新增重复路径检查函数
- 更新翻译文件,同步所有用户界面的中英文文本
2026-04-30 11:38:05 +08:00

34 lines
1.0 KiB
C

#ifndef STRING_EXT_H
#define STRING_EXT_H
#include <wchar.h>
// 简单字符串列表结构
typedef struct
{
char **items;
int count;
int capacity;
} StringList;
// 字符串列表
void init_string_list(StringList *list);
void add_string_list(StringList *list, const char *str);
void clear_string_list(StringList *list);
// 访问器函数 - 安全访问内部数据
// 获取指定索引的字符串(只读),越界返回 NULL
const char *string_list_get(const StringList *list, int index);
// 设置指定索引的字符串(会复制新字符串并释放旧字符串),越界返回 -1,成功返回 0
int string_list_set(StringList *list, int index, const char *str);
// 字符串转换函数
char *wide_to_utf8(const wchar_t *wstr);
wchar_t *utf8_to_wide(const char *str);
char *stristr(const char *haystack, const char *needle);
// 检查字符串列表中是否存在指定路径(不区分大小写)
int string_list_contains(const StringList *list, const char *str);
#endif // STRING_EXT_H