当前仓库属于暂停状态,部分功能使用受限,详情请查阅 仓库状态说明
24 Star 53 Fork 24

openGauss/Yukon
暂停

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
GSGUtil.cpp 2.19 KB
一键复制 编辑 原始数据 按行查看 历史
/*
 *
 * GSGUtil.cpp
 *
 * Copyright (C) 2021-2024 SuperMap Software Co., Ltd.
 *
 * Yukon is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; If not, see <http://www.gnu.org/licenses/>. *
 */
#include "GSGUtil.h"
/**
* @brief 将合法的小写字母转换成大写帘字母
*/
static char char_toupper(int in)
{
if (in < 0 || in > 127)
return '.';
if (in >= 'a' && in <= 'z')
{
return in - ('a' - 'A');
}
return in;
}
/**
* @brief 将 cstring 类型转换未 textp 类型
* @note 在 sql 定义的函数中,不支持 cstring 类型
* @param cstring
* @return text*
*/
/**
* @brief 将 hex 转换成可显示的 char
*
* @param c
* @return unsigned
*/
static unsigned char _Hex2Char(unsigned char c)
{
if (c == 0)
{
return '0';
}
else if (c < 0xa)
{
return c + 0x30;
}
else
{
return c + 0x37;
}
}
/**
* @brief
*
* @param src 要转换的 hex
* @param dst 转换后的字符
*/
void Hex2Char(unsigned char src, unsigned char *dst)
{
dst[1] = _Hex2Char(src >> 4);
dst[0] = _Hex2Char(src & 0x0f);
}
/**
* @brief 将字符转换成 Hex '01'->1 'fa'->fa
*
* @param c
* @return unsigned
*/
unsigned char _Char2Hex(const unsigned char c)
{
unsigned char t = char_toupper(c);
if (t == '0')
{
return 0;
}
else if (t >= 'A' && t <= 'F')
{
return t - 0x37;
}
else
{
return t - 0x30;
}
}
unsigned char Char2Hex(const unsigned char *c)
{
return (_Char2Hex(c[0]) << 4) + _Char2Hex(c[1]);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/opengauss/yukon.git
git@gitee.com:opengauss/yukon.git
opengauss
yukon
Yukon
master

搜索帮助