⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utils.cpp

📁 MONA是为数不多的C++语言编写的一个很小的操作系统
💻 CPP
字号:
// This software is in the public domain.
// There are no restrictions on any sort of usage of this software.

#include <monapi/string.h>
#include "utils.h"

unsigned int xtoui(const char* str)
{
	if (str == NULL) return 0;
	
	unsigned int ret = 0;
	int len = strlen(str);
	for (int i = len - 1, sh = 0; i >= 0; i--, sh += 4)
	{
		char ch = str[i];
		unsigned int v = 0;
		if ('0' <= ch && ch <= '9')
		{
			v = ch - '0';
		}
		else if ('A' <= ch && ch <= 'F')
		{
			v = ch - 'A' + 10;
		}
		else if ('a' <= ch && ch <= 'f')
		{
			v = ch - 'a' + 10;
		}
		else
		{
			return 0;
		}
		ret += v << sh;
	}
	return ret;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -