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

📄 utf.c

📁 在x86平台上运行不可信任代码的sandbox。
💻 C
📖 第 1 页 / 共 4 页
字号:
	0x1e1c, 501,	/* Ḝ ḝ */	0x1e1e, 501,	/* Ḟ ḟ */	0x1e20, 501,	/* Ḡ ḡ */	0x1e22, 501,	/* Ḣ ḣ */	0x1e24, 501,	/* Ḥ ḥ */	0x1e26, 501,	/* Ḧ ḧ */	0x1e28, 501,	/* Ḩ ḩ */	0x1e2a, 501,	/* Ḫ ḫ */	0x1e2c, 501,	/* Ḭ ḭ */	0x1e2e, 501,	/* Ḯ ḯ */	0x1e30, 501,	/* Ḱ ḱ */	0x1e32, 501,	/* Ḳ ḳ */	0x1e34, 501,	/* Ḵ ḵ */	0x1e36, 501,	/* Ḷ ḷ */	0x1e38, 501,	/* Ḹ ḹ */	0x1e3a, 501,	/* Ḻ ḻ */	0x1e3c, 501,	/* Ḽ ḽ */	0x1e3e, 501,	/* Ḿ ḿ */	0x1e40, 501,	/* Ṁ ṁ */	0x1e42, 501,	/* Ṃ ṃ */	0x1e44, 501,	/* Ṅ ṅ */	0x1e46, 501,	/* Ṇ ṇ */	0x1e48, 501,	/* Ṉ ṉ */	0x1e4a, 501,	/* Ṋ ṋ */	0x1e4c, 501,	/* Ṍ ṍ */	0x1e4e, 501,	/* Ṏ ṏ */	0x1e50, 501,	/* Ṑ ṑ */	0x1e52, 501,	/* Ṓ ṓ */	0x1e54, 501,	/* Ṕ ṕ */	0x1e56, 501,	/* Ṗ ṗ */	0x1e58, 501,	/* Ṙ ṙ */	0x1e5a, 501,	/* Ṛ ṛ */	0x1e5c, 501,	/* Ṝ ṝ */	0x1e5e, 501,	/* Ṟ ṟ */	0x1e60, 501,	/* Ṡ ṡ */	0x1e62, 501,	/* Ṣ ṣ */	0x1e64, 501,	/* Ṥ ṥ */	0x1e66, 501,	/* Ṧ ṧ */	0x1e68, 501,	/* Ṩ ṩ */	0x1e6a, 501,	/* Ṫ ṫ */	0x1e6c, 501,	/* Ṭ ṭ */	0x1e6e, 501,	/* Ṯ ṯ */	0x1e70, 501,	/* Ṱ ṱ */	0x1e72, 501,	/* Ṳ ṳ */	0x1e74, 501,	/* Ṵ ṵ */	0x1e76, 501,	/* Ṷ ṷ */	0x1e78, 501,	/* Ṹ ṹ */	0x1e7a, 501,	/* Ṻ ṻ */	0x1e7c, 501,	/* Ṽ ṽ */	0x1e7e, 501,	/* Ṿ ṿ */	0x1e80, 501,	/* Ẁ ẁ */	0x1e82, 501,	/* Ẃ ẃ */	0x1e84, 501,	/* Ẅ ẅ */	0x1e86, 501,	/* Ẇ ẇ */	0x1e88, 501,	/* Ẉ ẉ */	0x1e8a, 501,	/* Ẋ ẋ */	0x1e8c, 501,	/* Ẍ ẍ */	0x1e8e, 501,	/* Ẏ ẏ */	0x1e90, 501,	/* Ẑ ẑ */	0x1e92, 501,	/* Ẓ ẓ */	0x1e94, 501,	/* Ẕ ẕ */	0x1ea0, 501,	/* Ạ ạ */	0x1ea2, 501,	/* Ả ả */	0x1ea4, 501,	/* Ấ ấ */	0x1ea6, 501,	/* Ầ ầ */	0x1ea8, 501,	/* Ẩ ẩ */	0x1eaa, 501,	/* Ẫ ẫ */	0x1eac, 501,	/* Ậ ậ */	0x1eae, 501,	/* Ắ ắ */	0x1eb0, 501,	/* Ằ ằ */	0x1eb2, 501,	/* Ẳ ẳ */	0x1eb4, 501,	/* Ẵ ẵ */	0x1eb6, 501,	/* Ặ ặ */	0x1eb8, 501,	/* Ẹ ẹ */	0x1eba, 501,	/* Ẻ ẻ */	0x1ebc, 501,	/* Ẽ ẽ */	0x1ebe, 501,	/* Ế ế */	0x1ec0, 501,	/* Ề ề */	0x1ec2, 501,	/* Ể ể */	0x1ec4, 501,	/* Ễ ễ */	0x1ec6, 501,	/* Ệ ệ */	0x1ec8, 501,	/* Ỉ ỉ */	0x1eca, 501,	/* Ị ị */	0x1ecc, 501,	/* Ọ ọ */	0x1ece, 501,	/* Ỏ ỏ */	0x1ed0, 501,	/* Ố ố */	0x1ed2, 501,	/* Ồ ồ */	0x1ed4, 501,	/* Ổ ổ */	0x1ed6, 501,	/* Ỗ ỗ */	0x1ed8, 501,	/* Ộ ộ */	0x1eda, 501,	/* Ớ ớ */	0x1edc, 501,	/* Ờ ờ */	0x1ede, 501,	/* Ở ở */	0x1ee0, 501,	/* Ỡ ỡ */	0x1ee2, 501,	/* Ợ ợ */	0x1ee4, 501,	/* Ụ ụ */	0x1ee6, 501,	/* Ủ ủ */	0x1ee8, 501,	/* Ứ ứ */	0x1eea, 501,	/* Ừ ừ */	0x1eec, 501,	/* Ử ử */	0x1eee, 501,	/* Ữ ữ */	0x1ef0, 501,	/* Ự ự */	0x1ef2, 501,	/* Ỳ ỳ */	0x1ef4, 501,	/* Ỵ ỵ */	0x1ef6, 501,	/* Ỷ ỷ */	0x1ef8, 501,	/* Ỹ ỹ */	0x1f59, 492,	/* Ὑ ὑ */	0x1f5b, 492,	/* Ὓ ὓ */	0x1f5d, 492,	/* Ὕ ὕ */	0x1f5f, 492,	/* Ὗ ὗ */	0x1fbc, 491,	/* ᾼ ᾳ */	0x1fcc, 491,	/* ῌ ῃ */	0x1fec, 493,	/* Ῥ ῥ */	0x1ffc, 491,	/* ῼ ῳ */};/* * title characters are those between * upper and lower case. ie DZ Dz dz */staticRune	__totitle1[] ={	0x01c4, 501,	/* DŽ Dž */	0x01c6, 499,	/* dž Dž */	0x01c7, 501,	/* LJ Lj */	0x01c9, 499,	/* lj Lj */	0x01ca, 501,	/* NJ Nj */	0x01cc, 499,	/* nj Nj */	0x01f1, 501,	/* DZ Dz */	0x01f3, 499,	/* dz Dz */};static Rune*bsearch(Rune c, Rune *t, int n, int ne){	Rune *p;	int m;	while(n > 1) {		m = n/2;		p = t + m*ne;		if(c >= p[0]) {			t = p;			n = n-m;		} else			n = m;	}	if(n && c >= t[0])		return t;	return 0;}Runetolowerrune(Rune c){	Rune *p;	p = bsearch(c, __tolower2, nelem(__tolower2)/3, 3);	if(p && c >= p[0] && c <= p[1])		return c + p[2] - 500;	p = bsearch(c, __tolower1, nelem(__tolower1)/2, 2);	if(p && c == p[0])		return c + p[1] - 500;	return c;}Runetoupperrune(Rune c){	Rune *p;	p = bsearch(c, __toupper2, nelem(__toupper2)/3, 3);	if(p && c >= p[0] && c <= p[1])		return c + p[2] - 500;	p = bsearch(c, __toupper1, nelem(__toupper1)/2, 2);	if(p && c == p[0])		return c + p[1] - 500;	return c;}Runetotitlerune(Rune c){	Rune *p;	p = bsearch(c, __totitle1, nelem(__totitle1)/2, 2);	if(p && c == p[0])		return c + p[1] - 500;	return c;}intislowerrune(Rune c){	Rune *p;	p = bsearch(c, __toupper2, nelem(__toupper2)/3, 3);	if(p && c >= p[0] && c <= p[1])		return 1;	p = bsearch(c, __toupper1, nelem(__toupper1)/2, 2);	if(p && c == p[0])		return 1;	return 0;}intisupperrune(Rune c){	Rune *p;	p = bsearch(c, __tolower2, nelem(__tolower2)/3, 3);	if(p && c >= p[0] && c <= p[1])		return 1;	p = bsearch(c, __tolower1, nelem(__tolower1)/2, 2);	if(p && c == p[0])		return 1;	return 0;}intisalpharune(Rune c){	Rune *p;	if(isupperrune(c) || islowerrune(c))		return 1;	p = bsearch(c, __alpha2, nelem(__alpha2)/2, 2);	if(p && c >= p[0] && c <= p[1])		return 1;	p = bsearch(c, __alpha1, nelem(__alpha1), 1);	if(p && c == p[0])		return 1;	return 0;}intistitlerune(Rune c){	return isupperrune(c) && islowerrune(c);}intisspacerune(Rune c){	Rune *p;	p = bsearch(c, __space2, nelem(__space2)/2, 2);	if(p && c >= p[0] && c <= p[1])		return 1;	return 0;}/* -------------- utfecpy.c --------------- *//* * The authors of this software are Rob Pike and Ken Thompson. *              Copyright (c) 2002 by Lucent Technologies. * Permission to use, copy, modify, and distribute this software for any * purpose without fee is hereby granted, provided that this entire notice * is included in all copies of any software which is or includes a copy * or modification of this software and in all copies of the supporting * documentation for such software. * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED * WARRANTY.  IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE * ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */#define _BSD_SOURCE 1	/* memccpy */// #include <stdarg.h>// #include <string.h>// #include "plan9.h"// #include "utf.h"char*utfecpy(char *to, char *e, char *from){	char *end;	if(to >= e)		return to;	end = memccpy(to, from, '\0', e - to);	if(end == nil){		end = e-1;		while(end>to && (*--end&0xC0)==0x80)			;		*end = '\0';	}else{		end--;	}	return end;}/* -------------- utflen.c --------------- *//* * The authors of this software are Rob Pike and Ken Thompson. *              Copyright (c) 2002 by Lucent Technologies. * Permission to use, copy, modify, and distribute this software for any * purpose without fee is hereby granted, provided that this entire notice * is included in all copies of any software which is or includes a copy * or modification of this software and in all copies of the supporting * documentation for such software. * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED * WARRANTY.  IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE * ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */// #include <stdarg.h>// #include <string.h>// #include "plan9.h"// #include "utf.h"intutflen(char *s){	int c;	long n;	Rune rune;	n = 0;	for(;;) {		c = *(uchar*)s;		if(c < Runeself) {			if(c == 0)				return n;			s++;		} else			s += chartorune(&rune, s);		n++;	}}/* -------------- utfnlen.c --------------- *//* * The authors of this software are Rob Pike and Ken Thompson. *              Copyright (c) 2002 by Lucent Technologies. * Permission to use, copy, modify, and distribute this software for any * purpose without fee is hereby granted, provided that this entire notice * is included in all copies of any software which is or includes a copy * or modification of this software and in all copies of the supporting * documentation for such software. * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED * WARRANTY.  IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE * ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */// #include <stdarg.h>// #include <string.h>// #include "plan9.h"// #include "utf.h"intutfnlen(char *s, long m){	int c;	long n;	Rune rune;	char *es;	es = s + m;	for(n = 0; s < es; n++) {		c = *(uchar*)s;		if(c < Runeself){			if(c == '\0')				break;			s++;			continue;		}		if(!fullrune(s, es-s))			break;		s += chartorune(&rune, s);	}	return n;}/* -------------- utfrrune.c --------------- *//* * The authors of this software are Rob Pike and Ken Thompson. *              Copyright (c) 2002 by Lucent Technologies. * Permission to use, copy, modify, and distribute this software for any * purpose without fee is hereby granted, provided that this entire notice * is included in all copies of any software which is or includes a copy * or modification of this software and in all copies of the supporting * documentation for such software. * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED * WARRANTY.  IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE * ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */// #include <stdarg.h>// #include <string.h>// #include "plan9.h"// #include "utf.h"char*utfrrune(char *s, long c){	long c1;	Rune r;	char *s1;	if(c < Runesync)		/* not part of utf sequence */		return strrchr(s, c);	s1 = 0;	for(;;) {		c1 = *(uchar*)s;		if(c1 < Runeself) {	/* one byte rune */			if(c1 == 0)				return s1;			if(c1 == c)				s1 = s;			s++;			continue;		}		c1 = chartorune(&r, s);		if(r == c)			s1 = s;		s += c1;	}}/* -------------- utfrune.c --------------- *//* * The authors of this software are Rob Pike and Ken Thompson. *              Copyright (c) 2002 by Lucent Technologies. * Permission to use, copy, modify, and distribute this software for any * purpose without fee is hereby granted, provided that this entire notice * is included in all copies of any software which is or includes a copy * or modification of this software and in all copies of the supporting * documentation for such software. * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED * WARRANTY.  IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE * ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */// #include <stdarg.h>// #include <string.h>// #include "plan9.h"// #include "utf.h"char*utfrune(char *s, long c){	long c1;	Rune r;	int n;	if(c < Runesync)		/* not part of utf sequence */		return strchr(s, c);	for(;;) {		c1 = *(uchar*)s;		if(c1 < Runeself) {	/* one byte rune */			if(c1 == 0)				return 0;			if(c1 == c)				return s;			s++;			continue;		}		n = chartorune(&r, s);		if(r == c)			return s;		s += n;	}}/* -------------- utfutf.c --------------- *//* * The authors of this software are Rob Pike and Ken Thompson. *              Copyright (c) 2002 by Lucent Technologies. * Permission to use, copy, modify, and distribute this software for any * purpose without fee is hereby granted, provided that this entire notice * is included in all copies of any software which is or includes a copy * or modification of this software and in all copies of the supporting * documentation for such software. * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED * WARRANTY.  IN PARTICULAR, NEITHER THE AUTHORS NOR LUCENT TECHNOLOGIES MAKE * ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */// #include <stdarg.h>// #include <string.h>// #include "plan9.h"// #include "utf.h"/* * Return pointer to first occurrence of s2 in s1, * 0 if none */char*utfutf(char *s1, char *s2){	char *p;	long f, n1, n2;	Rune r;	n1 = chartorune(&r, s2);	f = r;	if(f <= Runesync)		/* represents self */		return strstr(s1, s2);	n2 = strlen(s2);	for(p=s1; (p=utfrune(p, f)); p+=n1)		if(strncmp(p, s2, n2) == 0)			return p;	return 0;}

⌨️ 快捷键说明

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