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 b2cfc4e2 2003-09-30 devnull will convert to 0x80 and return 1.
76 b2cfc4e2 2003-09-30 devnull .I Runelen
77 b2cfc4e2 2003-09-30 devnull returns the number of bytes
78 b2cfc4e2 2003-09-30 devnull required to convert
83 b2cfc4e2 2003-09-30 devnull .I Runenlen
84 b2cfc4e2 2003-09-30 devnull returns the number of bytes
85 b2cfc4e2 2003-09-30 devnull required to convert the
87 b2cfc4e2 2003-09-30 devnull runes pointed to by
92 b2cfc4e2 2003-09-30 devnull .I Fullrune
93 b2cfc4e2 2003-09-30 devnull returns 1 if the string
95 b2cfc4e2 2003-09-30 devnull of length
97 b2cfc4e2 2003-09-30 devnull is long enough to be decoded by
98 b2cfc4e2 2003-09-30 devnull .I chartorune
99 b2cfc4e2 2003-09-30 devnull and 0 otherwise.
100 b2cfc4e2 2003-09-30 devnull This does not guarantee that the string
101 b2cfc4e2 2003-09-30 devnull contains a legal
103 b2cfc4e2 2003-09-30 devnull encoding.
104 b2cfc4e2 2003-09-30 devnull This routine is used by programs that
105 b2cfc4e2 2003-09-30 devnull obtain input a byte at
106 b2cfc4e2 2003-09-30 devnull a time and need to know when a full rune
107 b2cfc4e2 2003-09-30 devnull has arrived.
109 b2cfc4e2 2003-09-30 devnull The following routines are analogous to the
110 b2cfc4e2 2003-09-30 devnull corresponding string routines with
112 b2cfc4e2 2003-09-30 devnull substituted for
116 b2cfc4e2 2003-09-30 devnull substituted for
117 b2cfc4e2 2003-09-30 devnull .BR chr .
119 b2cfc4e2 2003-09-30 devnull .I Utfecpy
120 b2cfc4e2 2003-09-30 devnull copies UTF sequences until a null sequence has been copied, but writes no
121 b2cfc4e2 2003-09-30 devnull sequences beyond
122 b2cfc4e2 2003-09-30 devnull .IR es1 .
123 b2cfc4e2 2003-09-30 devnull If any sequences are copied,
125 b2cfc4e2 2003-09-30 devnull is terminated by a null sequence, and a pointer to that sequence is returned.
126 b2cfc4e2 2003-09-30 devnull Otherwise, the original
128 b2cfc4e2 2003-09-30 devnull is returned.
130 b2cfc4e2 2003-09-30 devnull .I Utflen
131 b2cfc4e2 2003-09-30 devnull returns the number of runes that
132 b2cfc4e2 2003-09-30 devnull are represented by the
137 b2cfc4e2 2003-09-30 devnull .I Utfnlen
138 b2cfc4e2 2003-09-30 devnull returns the number of complete runes that
139 b2cfc4e2 2003-09-30 devnull are represented by the first
141 b2cfc4e2 2003-09-30 devnull bytes of
145 b2cfc4e2 2003-09-30 devnull If the last few bytes of the string contain an incompletely coded rune,
146 b2cfc4e2 2003-09-30 devnull .I utfnlen
147 b2cfc4e2 2003-09-30 devnull will not count them; in this way, it differs from
148 b2cfc4e2 2003-09-30 devnull .IR utflen ,
149 b2cfc4e2 2003-09-30 devnull which includes every byte of the string.
151 b2cfc4e2 2003-09-30 devnull .I Utfrune
152 b2cfc4e2 2003-09-30 devnull .RI ( utfrrune )
153 b2cfc4e2 2003-09-30 devnull returns a pointer to the first (last)
154 b2cfc4e2 2003-09-30 devnull occurrence of rune
162 b2cfc4e2 2003-09-30 devnull does not occur in the string.
163 b2cfc4e2 2003-09-30 devnull The NUL byte terminating a string is considered to
164 b2cfc4e2 2003-09-30 devnull be part of the string
167 b2cfc4e2 2003-09-30 devnull .I Utfutf
168 b2cfc4e2 2003-09-30 devnull returns a pointer to the first occurrence of
175 b2cfc4e2 2003-09-30 devnull substring of
176 b2cfc4e2 2003-09-30 devnull .IR s1 ,
177 b2cfc4e2 2003-09-30 devnull or 0 if there is none.
180 b2cfc4e2 2003-09-30 devnull is the null string,
181 b2cfc4e2 2003-09-30 devnull .I utfutf
183 b2cfc4e2 2003-09-30 devnull .IR s1 .
184 cfa37a7b 2004-04-10 devnull .SH SOURCE
185 c3674de4 2005-01-11 devnull .B \*9/src/lib9/utf/rune.c
187 c3674de4 2005-01-11 devnull .B \*9/src/lib9/utf/utfrune.c
188 b2cfc4e2 2003-09-30 devnull .SH SEE ALSO
189 058b0118 2005-01-03 devnull .IR utf (7),
190 b2cfc4e2 2003-09-30 devnull .IR tcs (1)