Skip to content

Instantly share code, notes, and snippets.

@markqiu
markqiu / isgbk.c
Created January 29, 2016 14:06 — forked from neesenk/isgbk.c
判断一个字串是否是GBK编码
/* http://en.wikipedia.org/wiki/GBK */
size_t fixGBK(const char *str, size_t len)
{
const unsigned char *string = (const unsigned char *)str;
size_t idx = 0;
for (idx = 0; idx < len; idx++) {
int val = string[idx], val2;
if (val < 128)
continue;
if (idx + 1 >= len)