ngl_server 1.0
基于 Actor 模型的 C++ 服务器框架
tools_text.h File Reference

文本处理工具:字符编码转换、正则表达式、URL编解码、字符串操作。 More...

#include "tools_core.h"

Namespaces

namespace  ngl::tools
 工具函数命名空间。

Functions

bool ngl::tools::wasscii2asscii (const std::wstring &awstr, std::string &astr)
 将宽字符串(wstring)转换为多字节ASCII字符串
bool ngl::tools::asscii2wasscii (const std::string &astr, std::wstring &awstr)
 将多字节ASCII字符串转换为宽字符串(wstring)
bool ngl::tools::wasscii2utf8 (const std::wstring &awstr, std::string &astr)
 将宽字符串(wstring)转换为UTF-8字符串
bool ngl::tools::utf82wasscii (const std::string &astr, std::wstring &awstr)
 将UTF-8字符串转换为宽字符串(wstring)
bool ngl::tools::to_asscii (const std::string &astr1, std::string &astr2)
 将UTF-8字符串转换为多字节ASCII字符串
bool ngl::tools::to_utf8 (const std::string &astr1, std::string &astr2)
 将多字节ASCII字符串转换为UTF-8字符串
int32_t ngl::tools::utf8firstbyte (uint8_t afirst)
 获取UTF-8编码第一个字节的字节数
bool ngl::tools::isutf8 (const std::string &astr)
 检查字符串是否为有效的UTF-8编码
bool ngl::tools::isincludeutf8mb4 (const std::string &astr)
 检查UTF-8字符串是否包含4字节字符(UTF-8mb4)
void ngl::tools::sregex (const std::string &apattern, const std::string &adata, const std::function< void(std::string &)> &afun)
 使用正则表达式查找所有匹配的子串
void ngl::tools::smatch (const std::string &aexpr, const std::string &adata, const std::function< void(std::smatch &)> &afun)
 使用正则表达式查找所有匹配并获取捕获组
void ngl::tools::replace (const std::string &aexpr, const std::string &arepl, const std::string &adata, std::string &aret)
 使用正则表达式替换字符串
std::string ngl::tools::char2hex (char adec)
 将单个字符转换为两位十六进制字符串
std::string ngl::tools::url_encode (const std::string &astr)
 URL编码字符串
std::string ngl::tools::url_decode (const std::string &astr)
 URL解码字符串
std::vector< std::string_view > ngl::tools::get_line (const char *apbuff, std::size_t abuff_sz)
 按行分割字符缓冲区
bool ngl::tools::isnumber (const std::string &anum)
 检查字符串是否全部由数字组成
void ngl::tools::transform_tolower (std::string &adata)
 将字符串转换为小写
void ngl::tools::transform_toupper (std::string &adata)
 将字符串转换为大写

Detailed Description

文本处理工具:字符编码转换、正则表达式、URL编解码、字符串操作。

提供丰富的文本处理功能,包括:

  • ASCII/宽字符/UTF-8编码转换
  • 正则表达式匹配和替换
  • URL编码和解码
  • 大小写转换、数字判断等基础字符串操作