本文整理汇总了C++中runetochar函数的典型用法代码示例。如果您正苦于以下问题:C++ runetochar函数的具体用法?C++ runetochar怎么用?C++ runetochar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了runetochar函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gostringsize
void
runtime·slicerunetostring(Slice b, String s)
{
#line 3599 "C:\Go\src\pkg\runtime\string.goc"
int32 siz1, siz2, i;
int32 *a;
byte dum[8];
a = (int32*)b.array;
siz1 = 0;
for(i=0; i<b.len; i++) {
siz1 += runtime·runetochar(dum, a[i]);
}
s = gostringsize(siz1+4);
siz2 = 0;
for(i=0; i<b.len; i++) {
// check for race
if(siz2 >= siz1)
break;
siz2 += runtime·runetochar(s.str+siz2, a[i]);
}
s.len = siz2;
s.str[s.len] = 0;
FLUSH(&s);
}
示例2: FLUSH
void
runtime·slicerunetostring(Slice b, String s)
{
s.str = 0;
s.len = 0;
FLUSH(&s);
#line 309 "/home/14/ren/source/golang/go/src/pkg/runtime/string.goc"
intgo siz1, siz2, i;
int32 *a;
byte dum[8];
void *pc;
if(raceenabled) {
pc = runtime·getcallerpc(&b);
runtime·racereadrangepc(b.array, b.len*sizeof(*a), pc, runtime·slicerunetostring);
}
a = (int32*)b.array;
siz1 = 0;
for(i=0; i<b.len; i++) {
siz1 += runtime·runetochar(dum, a[i]);
}
s = gostringsize(siz1+4);
siz2 = 0;
for(i=0; i<b.len; i++) {
// check for race
if(siz2 >= siz1)
break;
siz2 += runtime·runetochar(s.str+siz2, a[i]);
}
s.len = siz2;
s.str[s.len] = 0;
FLUSH(&s);
}
示例3: gkbdputc
void
gkbdputc(Queue *q, int ch)
{
int n;
Rune r;
static uchar kc[5*UTFmax];
static int nk, collecting = 0;
char buf[UTFmax];
r = ch;
if(r == Latin) {
collecting = 1;
nk = 0;
return;
}
if(collecting) {
int c;
nk += runetochar((char*)&kc[nk], &r);
c = latin1(kc, nk);
if(c < -1) /* need more keystrokes */
return;
collecting = 0;
if(c == -1) { /* invalid sequence */
qproduce(q, kc, nk);
return;
}
r = (Rune)c;
}
n = runetochar(buf, &r);
if(n == 0)
return;
/* if(!isdbgkey(r)) */
qproduce(q, buf, n);
}
示例4: fz_malloc
static char *convert_to_utf8(fz_context *doc, unsigned char *s, int n)
{
unsigned char *e = s + n;
char *dst, *d;
int c;
if (s[0] == 0xFE && s[1] == 0xFF) {
dst = d = fz_malloc(doc, n * 2);
while (s + 1 < e) {
c = s[0] << 8 | s[1];
d += runetochar(d, &c);
s += 2;
}
*d = 0;
return dst;
}
if (s[0] == 0xFF && s[1] == 0xFE) {
dst = d = fz_malloc(doc, n * 2);
while (s + 1 < e) {
c = s[0] | s[1] << 8;
d += runetochar(d, &c);
s += 2;
}
*d = 0;
return dst;
}
return (char*)s;
}
示例5: pdf_to_utf8
/* Convert Unicode/PdfDocEncoding string into utf-8 */
char *
pdf_to_utf8(fz_obj *src)
{
unsigned char *srcptr = (unsigned char *) fz_to_str_buf(src);
char *dstptr, *dst;
int srclen = fz_to_str_len(src);
int dstlen = 0;
int ucs;
int i;
if (srclen >= 2 && srcptr[0] == 254 && srcptr[1] == 255)
{
for (i = 2; i + 1 < srclen; i += 2)
{
ucs = srcptr[i] << 8 | srcptr[i+1];
dstlen += runelen(ucs);
}
dstptr = dst = fz_malloc(dstlen + 1);
for (i = 2; i + 1 < srclen; i += 2)
{
ucs = srcptr[i] << 8 | srcptr[i+1];
dstptr += runetochar(dstptr, &ucs);
}
}
else if (srclen >= 2 && srcptr[0] == 255 && srcptr[1] == 254)
{
for (i = 2; i + 1 < srclen; i += 2)
{
ucs = srcptr[i] | srcptr[i+1] << 8;
dstlen += runelen(ucs);
}
dstptr = dst = fz_malloc(dstlen + 1);
for (i = 2; i + 1 < srclen; i += 2)
{
ucs = srcptr[i] | srcptr[i+1] << 8;
dstptr += runetochar(dstptr, &ucs);
}
}
else
{
for (i = 0; i < srclen; i++)
dstlen += runelen(pdf_doc_encoding[srcptr[i]]);
dstptr = dst = fz_malloc(dstlen + 1);
for (i = 0; i < srclen; i++)
{
ucs = pdf_doc_encoding[srcptr[i]];
dstptr += runetochar(dstptr, &ucs);
}
}
*dstptr = '\0';
return dst;
}
示例6: pdf_toutf8
fz_error *
pdf_toutf8(char **dstp, fz_obj *src)
{
unsigned char *srcptr = fz_tostrbuf(src);
char *dstptr;
int srclen = fz_tostrlen(src);
int dstlen = 0;
int ucs;
int i;
if (srclen > 2 && srcptr[0] == 254 && srcptr[1] == 255)
{
for (i = 2; i < srclen; i += 2)
{
ucs = (srcptr[i] << 8) | srcptr[i+1];
dstlen += runelen(ucs);
}
dstptr = *dstp = fz_malloc(dstlen + 1);
if (!dstptr)
return fz_outofmem;
for (i = 2; i < srclen; i += 2)
{
ucs = (srcptr[i] << 8) | srcptr[i+1];
dstptr += runetochar(dstptr, &ucs);
}
}
else
{
for (i = 0; i < srclen; i++)
dstlen += runelen(pdf_docencoding[srcptr[i]]);
dstptr = *dstp = fz_malloc(dstlen + 1);
if (!dstptr)
return fz_outofmem;
for (i = 0; i < srclen; i++)
{
ucs = pdf_docencoding[srcptr[i]];
dstptr += runetochar(dstptr, &ucs);
}
}
*dstptr = '\0';
return nil;
}
示例7: utfrune
char *
utfrune(const char *s, Rune r)
{
if(r < Runeself) {
return strchr(s, r);
}
else if(r == Runeerror) {
Rune r0;
int n;
for(; *s != '\0'; s += n) {
n = chartorune(&r0, s);
if(r == r0)
return (char *)s;
}
}
else {
char buf[UTFmax+1];
int n;
if(!(n = runetochar(buf, &r)))
return NULL;
buf[n] = '\0';
return strstr(s, buf);
}
return NULL;
}
示例8: map
static char *
map(Rune rp[], int font) /* figure out mapping for char in this font */
{
static char s[100];
char c[10];
Link *p;
Rune r;
if(rp[1]==0 && rp[0]<QUICK) /* fast lookup */
r = charmap[fmap[font]].quick[rp[0]];
else { /* high-valued or compound character name */
sprint(c, "%S", rp);
r = 0;
for (p = charmap[fmap[font]].slow; p; p = p->next)
if(eq(c, p->name)){
r = p->val;
break;
}
}
if(r == 0){ /* not there */
dprint(2, "didn't find %S font# %d\n", rp, font);
return 0;
}
dprint(2, "map %S to %s font# %d\n", rp, s, font);
s[runetochar(s, &r)] = 0;
return s;
}
示例9: fz_debug_text_span
void
fz_debug_text_span(fz_text_span *span)
{
char buf[10];
int c, n, k, i;
while (span)
{
for (i = 0; i < span->len; i++)
{
c = span->text[i].c;
if (c < 128)
putchar(c);
else
{
n = runetochar(buf, &c);
for (k = 0; k < n; k++)
putchar(buf[k]);
}
}
if (span->eol)
putchar('\n');
span = span->next;
}
}
示例10: smbstringdup
char *
smbstringdup(SmbHeader *h, uchar *base, uchar **bdatap, uchar *edata)
{
char *p;
if (h && h->flags2 & SMB_FLAGS2_UNICODE) {
uchar *bdata = *bdatap;
uchar *savebdata;
Rune r;
int l;
char *q;
l = 0;
if ((bdata - base) & 1)
bdata++;
savebdata = bdata;
do {
if (bdata + 2 > edata)
return nil;
r = smbnhgets(bdata); bdata += 2;
l += runelen(r);
} while (r != 0);
p = smbemalloc(l);
bdata = savebdata;
q = p;
do {
r = smbnhgets(bdata); bdata += 2;
q += runetochar(q, &r);
} while (r != 0);
*bdatap = bdata;
return p;
}
return smbstrdup(bdatap, edata);
}
示例11: fromlatin1
/*
* convert from latin1 to utf
*/
static char*
fromlatin1(char *from)
{
char *p, *to;
Rune r;
if(os == Plan9)
return nil;
/* don't convert if we don't have to */
for(p = from; *p; p++)
if(*p & 0x80)
break;
if(*p == 0)
return nil;
to = malloc(3*strlen(from)+2);
if(to == nil)
return nil;
for(p = to; *from; from++){
r = (*from) & 0xff;
p += runetochar(p, &r);
}
*p = 0;
return to;
}
示例12: exportname
/* From Plan 9 to Unix */
char*
exportname(char* name)
{
Rune r;
int nr;
char *uxname;
char *up;
if (name == 0 ||
(utfrune(name, altspc) == 0 &&
utfrune(name,altlparen) == 0 &&
utfrune(name,altrparen) == 0 &&
utfrune(name,altamp) == 0 &&
utfrune(name,altquote) == 0))
return name;
up = uxname = emalloc(strlen(name) + 1);
names[nnames++] = uxname;
while(*name != 0){
nr = chartorune(&r, name);
if (r == altspc)
r = ' ';
if (r == altlparen)
r = '(';
if (r == altrparen)
r = ')';
if (r == altamp)
r = '&';
if (r == altquote)
r = '\'';
up += runetochar(up, &r);
name += nr;
}
*up = 0;
return uxname;
}
示例13: windocopy
void windocopy(pdfapp_t *app)
{
unsigned short copyucs2[16 * 1024];
char *latin1 = copylatin1;
char *utf8 = copyutf8;
unsigned short *ucs2;
int ucs;
pdfapp_oncopy(&gapp, copyucs2, 16 * 1024);
for (ucs2 = copyucs2; ucs2[0] != 0; ucs2++)
{
ucs = ucs2[0];
utf8 += runetochar(utf8, &ucs);
if (ucs < 256)
*latin1++ = ucs;
else
*latin1++ = '?';
}
*utf8 = 0;
*latin1 = 0;
printf("oncopy utf8=%zd latin1=%zd\n", strlen(copyutf8), strlen(copylatin1));
XSetSelectionOwner(xdpy, XA_PRIMARY, xwin, copytime);
justcopied = 1;
}
示例14: fz_debug_text_span_xml
void
fz_debug_text_span_xml(fz_text_span *span)
{
char buf[10];
int c, n, k, i;
while (span)
{
printf("<span font=\"%s\" size=\"%g\" wmode=\"%d\" eol=\"%d\">\n",
span->font ? span->font->name : "NULL", span->size, span->wmode, span->eol);
for (i = 0; i < span->len; i++)
{
printf("\t<char ucs=\"");
c = span->text[i].c;
if (c < 128)
putchar(c);
else
{
n = runetochar(buf, &c);
for (k = 0; k < n; k++)
putchar(buf[k]);
}
printf("\" bbox=\"%d %d %d %d\" />\n",
span->text[i].bbox.x0,
span->text[i].bbox.y0,
span->text[i].bbox.x1,
span->text[i].bbox.y1);
}
printf("</span>\n");
span = span->next;
}
}
示例15: fputrune
int
fputrune(const Rune *r, FILE *fp)
{
char buf[UTFmax];
return fwrite(buf, runetochar(buf, r), 1, fp);
}