Skip to content

Instantly share code, notes, and snippets.

View rise-worlds's full-sized avatar
🎯
Focusing

rise rise-worlds

🎯
Focusing
View GitHub Profile
@rise-worlds
rise-worlds / GetAvatar.cs
Last active December 5, 2016 09:13
use gravatar.com
public static class SignatureExtensions
{
static Dictionary<string, string> avatars = new Dictionary<string, string>();
public static string GetAvatar(this String email, int size = 75)
{
string key = email + "_" + size;
if (!avatars.ContainsKey(key))
{
string avatar = "//www.gravatar.com/avatar/";
@rise-worlds
rise-worlds / half.cpp
Last active October 13, 2016 08:58
utf8编码的全角字符转半角字符
//全角字符的定义为 unicode编码从0xFF01~0xFF5E 对应的半角字符为 半角字符unicode编码从0x21~0x7E,空格比较特殊, 全角为0x3000, 半角为0x20;除空格外, 全角/半角按unicode编码排序在顺序上是对应的
//首先,全角字符在utf-8下是三个字节表示,,具体表示为 1110xxxx 10xxxxxx 10xxxxxx
//所以,首先需要解析utf8编码的数据,如果是 FF01 到 FF5E 的情况下,则进行转换
void PreProcessor::half(std::string &input) {
std::string temp;
for (size_t i = 0; i < input.size(); i++) {
if (((input[i] & 0xF0) ^ 0xE0) == 0) {