1 b2cfc4e2 2003-09-30 devnull .TH RUNE 3
3 b2cfc4e2 2003-09-30 devnull runetochar, chartorune, runelen, runenlen, fullrune, utfecpy, utflen, utfnlen, utfrune, utfrrune, utfutf \- rune/UTF conversion
4 b2cfc4e2 2003-09-30 devnull .SH SYNOPSIS
5 b2cfc4e2 2003-09-30 devnull .ta \w'\fLchar*xx'u
6 cfa37a7b 2004-04-10 devnull .B #include <u.h>
8 cfa37a7b 2004-04-10 devnull .B #include <libc.h>
11 b2cfc4e2 2003-09-30 devnull int runetochar(char *s, Rune *r)
14 b2cfc4e2 2003-09-30 devnull int chartorune(Rune *r, char *s)
17 b2cfc4e2 2003-09-30 devnull int runelen(long r)
20 b2cfc4e2 2003-09-30 devnull int runenlen(Rune *r, int n)
23 b2cfc4e2 2003-09-30 devnull int fullrune(char *s, int n)
26 b2cfc4e2 2003-09-30 devnull char* utfecpy(char *s1, char *es1, char *s2)
29 b2cfc4e2 2003-09-30 devnull int utflen(char *s)
32 b2cfc4e2 2003-09-30 devnull int utfnlen(char *s, long n)
35 b2cfc4e2 2003-09-30 devnull char* utfrune(char *s, long c)
38 b2cfc4e2 2003-09-30 devnull char* utfrrune(char *s, long c)
41 b2cfc4e2 2003-09-30 devnull char* utfutf(char *s1, char *s2)
42 b2cfc4e2 2003-09-30 devnull .SH DESCRIPTION
43 b2cfc4e2 2003-09-30 devnull These routines convert to and from a
45 b2cfc4e2 2003-09-30 devnull byte stream and runes.
47 b2cfc4e2 2003-09-30 devnull .I Runetochar
48 b2cfc4e2 2003-09-30 devnull copies one rune at
50 b2cfc4e2 2003-09-30 devnull to at most
51 b2cfc4e2 2003-09-30 devnull .B UTFmax
52 b2cfc4e2 2003-09-30 devnull bytes starting at
54 b2cfc4e2 2003-09-30 devnull and returns the number of bytes copied.
55 b2cfc4e2 2003-09-30 devnull .BR UTFmax ,
56 b2cfc4e2 2003-09-30 devnull defined as
59 b2cfc4e2 2003-09-30 devnull .BR <libc.h> ,
60 b2cfc4e2 2003-09-30 devnull is the maximum number of bytes required to represent a rune.
62 b2cfc4e2 2003-09-30 devnull .I Chartorune
63 b2cfc4e2 2003-09-30 devnull copies at most
64 b2cfc4e2 2003-09-30 devnull .B UTFmax
65 b2cfc4e2 2003-09-30 devnull bytes starting at
67 b2cfc4e2 2003-09-30 devnull to one rune at
69 b2cfc4e2 2003-09-30 devnull and returns the number of bytes copied.
70 b2cfc4e2 2003-09-30 devnull If the input is not exactly in
73 b2cfc4e2 2003-09-30 devnull .I chartorune
74 2fe14f13 2010-03-09 rsc will convert to
77 2fe14f13 2010-03-09 rsc and return 1.
79 b2cfc4e2 2003-09-30 devnull .I Runelen
80 b2cfc4e2 2003-09-30 devnull returns the number of bytes
81 b2cfc4e2 2003-09-30 devnull required to convert
86 b2cfc4e2 2003-09-30 devnull .I Runenlen
87 b2cfc4e2 2003-09-30 devnull returns the number of bytes
88 b2cfc4e2 2003-09-30 devnull required to convert the
90 b2cfc4e2 2003-09-30 devnull runes pointed to by
95 b2cfc4e2 2003-09-30 devnull .I Fullrune
96 b2cfc4e2 2003-09-30 devnull returns 1 if the string
98 b2cfc4e2 2003-09-30 devnull of length
100 b2cfc4e2 2003-09-30 devnull is long enough to be decoded by
101 b2cfc4e2 2003-09-30 devnull .I chartorune
102 b2cfc4e2 2003-09-30 devnull and 0 otherwise.
103 b2cfc4e2 2003-09-30 devnull This does not guarantee that the string
104 b2cfc4e2 2003-09-30 devnull contains a legal
106 b2cfc4e2 2003-09-30 devnull encoding.
107 b2cfc4e2 2003-09-30 devnull This routine is used by programs that
108 b2cfc4e2 2003-09-30 devnull obtain input a byte at
109 b2cfc4e2 2003-09-30 devnull a time and need to know when a full rune
110 b2cfc4e2 2003-09-30 devnull has arrived.
112 b2cfc4e2 2003-09-30 devnull The following routines are analogous to the
113 b2cfc4e2 2003-09-30 devnull corresponding string routines with
115 b2cfc4e2 2003-09-30 devnull substituted for
119 b2cfc4e2 2003-09-30 devnull substituted for
120 b2cfc4e2 2003-09-30 devnull .BR chr .
122 b2cfc4e2 2003-09-30 devnull .I Utfecpy
123 b2cfc4e2 2003-09-30 devnull copies UTF sequences until a null sequence has been copied, but writes no
124 b2cfc4e2 2003-09-30 devnull sequences beyond
125 b2cfc4e2 2003-09-30 devnull .IR es1 .
126 b2cfc4e2 2003-09-30 devnull If any sequences are copied,
128 b2cfc4e2 2003-09-30 devnull is terminated by a null sequence, and a pointer to that sequence is returned.
129 b2cfc4e2 2003-09-30 devnull Otherwise, the original
131 b2cfc4e2 2003-09-30 devnull is returned.
133 b2cfc4e2 2003-09-30 devnull .I Utflen
134 b2cfc4e2 2003-09-30 devnull returns the number of runes that
135 b2cfc4e2 2003-09-30 devnull are represented by the
140 b2cfc4e2 2003-09-30 devnull .I Utfnlen
141 b2cfc4e2 2003-09-30 devnull returns the number of complete runes that
142 b2cfc4e2 2003-09-30 devnull are represented by the first
144 b2cfc4e2 2003-09-30 devnull bytes of
148 b2cfc4e2 2003-09-30 devnull If the last few bytes of the string contain an incompletely coded rune,
149 b2cfc4e2 2003-09-30 devnull .I utfnlen
150 b2cfc4e2 2003-09-30 devnull will not count them; in this way, it differs from
151 b2cfc4e2 2003-09-30 devnull .IR utflen ,
152 b2cfc4e2 2003-09-30 devnull which includes every byte of the string.
154 b2cfc4e2 2003-09-30 devnull .I Utfrune
155 b2cfc4e2 2003-09-30 devnull .RI ( utfrrune )
156 b2cfc4e2 2003-09-30 devnull returns a pointer to the first (last)
157 b2cfc4e2 2003-09-30 devnull occurrence of rune
165 b2cfc4e2 2003-09-30 devnull does not occur in the string.
166 b2cfc4e2 2003-09-30 devnull The NUL byte terminating a string is considered to
167 b2cfc4e2 2003-09-30 devnull be part of the string
170 b2cfc4e2 2003-09-30 devnull .I Utfutf
171 b2cfc4e2 2003-09-30 devnull returns a pointer to the first occurrence of
178 b2cfc4e2 2003-09-30 devnull substring of
179 b2cfc4e2 2003-09-30 devnull .IR s1 ,
180 b2cfc4e2 2003-09-30 devnull or 0 if there is none.
183 b2cfc4e2 2003-09-30 devnull is the null string,
184 b2cfc4e2 2003-09-30 devnull .I utfutf
186 b2cfc4e2 2003-09-30 devnull .IR s1 .
187 cfa37a7b 2004-04-10 devnull .SH SOURCE
188 c3674de4 2005-01-11 devnull .B \*9/src/lib9/utf/rune.c
190 c3674de4 2005-01-11 devnull .B \*9/src/lib9/utf/utfrune.c
191 b2cfc4e2 2003-09-30 devnull .SH SEE ALSO
192 058b0118 2005-01-03 devnull .IR utf (7),
193 b2cfc4e2 2003-09-30 devnull .IR tcs (1)