Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_posix/sys/src/cmd/unix/drawterm/gui-win32/wstrtoutf.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
 
4
int
5
wstrutflen(Rune *s)
6
{
7
	int n;
8
 
9
	for(n=0; *s; n+=runelen(*s),s++)
10
		;
11
	return n;
12
}
13
 
14
int
15
wstrtoutf(char *s, Rune *t, int n)
16
{
17
	int i;
18
	char *s0;
19
 
20
	s0 = s;
21
	if(n <= 0)
22
		return wstrutflen(t)+1;
23
	while(*t) {
24
		if(n < UTFmax+1 && n < runelen(*t)+1) {
25
			*s = 0;
26
			return i+wstrutflen(t)+1;
27
		}
28
		i = runetochar(s, t);
29
		s += i;
30
		n -= i;
31
		t++;
32
	}
33
	*s = 0;
34
	return s-s0;
35
}