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 b2cfc4e2 2003-09-30 devnull .B #include <utf.h>
9 b2cfc4e2 2003-09-30 devnull int runetochar(char *s, Rune *r)
12 b2cfc4e2 2003-09-30 devnull int chartorune(Rune *r, char *s)
15 b2cfc4e2 2003-09-30 devnull int runelen(long r)
18 b2cfc4e2 2003-09-30 devnull int runenlen(Rune *r, int n)
21 b2cfc4e2 2003-09-30 devnull int fullrune(char *s, int n)
24 b2cfc4e2 2003-09-30 devnull char* utfecpy(char *s1, char *es1, char *s2)
27 b2cfc4e2 2003-09-30 devnull int utflen(char *s)
30 b2cfc4e2 2003-09-30 devnull int utfnlen(char *s, long n)
33 b2cfc4e2 2003-09-30 devnull char* utfrune(char *s, long c)
36 b2cfc4e2 2003-09-30 devnull char* utfrrune(char *s, long c)
39 b2cfc4e2 2003-09-30 devnull char* utfutf(char *s1, char *s2)
40 b2cfc4e2 2003-09-30 devnull .SH DESCRIPTION
41 b2cfc4e2 2003-09-30 devnull These routines convert to and from a
43 b2cfc4e2 2003-09-30 devnull byte stream and runes.
45 b2cfc4e2 2003-09-30 devnull .I Runetochar
46 b2cfc4e2 2003-09-30 devnull copies one rune at
48 b2cfc4e2 2003-09-30 devnull to at most
49 b2cfc4e2 2003-09-30 devnull .B UTFmax
50 b2cfc4e2 2003-09-30 devnull bytes starting at
52 b2cfc4e2 2003-09-30 devnull and returns the number of bytes copied.
53 b2cfc4e2 2003-09-30 devnull .BR UTFmax ,
54 b2cfc4e2 2003-09-30 devnull defined as
57 b2cfc4e2 2003-09-30 devnull .BR <libc.h> ,
58 b2cfc4e2 2003-09-30 devnull is the maximum number of bytes required to represent a rune.
60 b2cfc4e2 2003-09-30 devnull .I Chartorune
61 b2cfc4e2 2003-09-30 devnull copies at most
62 b2cfc4e2 2003-09-30 devnull .B UTFmax
63 b2cfc4e2 2003-09-30 devnull bytes starting at
65 b2cfc4e2 2003-09-30 devnull to one rune at
67 b2cfc4e2 2003-09-30 devnull and returns the number of bytes copied.
68 b2cfc4e2 2003-09-30 devnull If the input is not exactly in
71 b2cfc4e2 2003-09-30 devnull .I chartorune
72 b2cfc4e2 2003-09-30 devnull will convert to 0x80 and return 1.
74 b2cfc4e2 2003-09-30 devnull .I Runelen
75 b2cfc4e2 2003-09-30 devnull returns the number of bytes
76 b2cfc4e2 2003-09-30 devnull required to convert
81 b2cfc4e2 2003-09-30 devnull .I Runenlen
82 b2cfc4e2 2003-09-30 devnull returns the number of bytes
83 b2cfc4e2 2003-09-30 devnull required to convert the
85 b2cfc4e2 2003-09-30 devnull runes pointed to by
90 b2cfc4e2 2003-09-30 devnull .I Fullrune
91 b2cfc4e2 2003-09-30 devnull returns 1 if the string
93 b2cfc4e2 2003-09-30 devnull of length
95 b2cfc4e2 2003-09-30 devnull is long enough to be decoded by
96 b2cfc4e2 2003-09-30 devnull .I chartorune
97 b2cfc4e2 2003-09-30 devnull and 0 otherwise.
98 b2cfc4e2 2003-09-30 devnull This does not guarantee that the string
99 b2cfc4e2 2003-09-30 devnull contains a legal
101 b2cfc4e2 2003-09-30 devnull encoding.
102 b2cfc4e2 2003-09-30 devnull This routine is used by programs that
103 b2cfc4e2 2003-09-30 devnull obtain input a byte at
104 b2cfc4e2 2003-09-30 devnull a time and need to know when a full rune
105 b2cfc4e2 2003-09-30 devnull has arrived.
107 b2cfc4e2 2003-09-30 devnull The following routines are analogous to the
108 b2cfc4e2 2003-09-30 devnull corresponding string routines with
110 b2cfc4e2 2003-09-30 devnull substituted for
114 b2cfc4e2 2003-09-30 devnull substituted for
115 b2cfc4e2 2003-09-30 devnull .BR chr .
117 b2cfc4e2 2003-09-30 devnull .I Utfecpy
118 b2cfc4e2 2003-09-30 devnull copies UTF sequences until a null sequence has been copied, but writes no
119 b2cfc4e2 2003-09-30 devnull sequences beyond
120 b2cfc4e2 2003-09-30 devnull .IR es1 .
121 b2cfc4e2 2003-09-30 devnull If any sequences are copied,
123 b2cfc4e2 2003-09-30 devnull is terminated by a null sequence, and a pointer to that sequence is returned.
124 b2cfc4e2 2003-09-30 devnull Otherwise, the original
126 b2cfc4e2 2003-09-30 devnull is returned.
128 b2cfc4e2 2003-09-30 devnull .I Utflen
129 b2cfc4e2 2003-09-30 devnull returns the number of runes that
130 b2cfc4e2 2003-09-30 devnull are represented by the
135 b2cfc4e2 2003-09-30 devnull .I Utfnlen
136 b2cfc4e2 2003-09-30 devnull returns the number of complete runes that
137 b2cfc4e2 2003-09-30 devnull are represented by the first
139 b2cfc4e2 2003-09-30 devnull bytes of
143 b2cfc4e2 2003-09-30 devnull If the last few bytes of the string contain an incompletely coded rune,
144 b2cfc4e2 2003-09-30 devnull .I utfnlen
145 b2cfc4e2 2003-09-30 devnull will not count them; in this way, it differs from
146 b2cfc4e2 2003-09-30 devnull .IR utflen ,
147 b2cfc4e2 2003-09-30 devnull which includes every byte of the string.
149 b2cfc4e2 2003-09-30 devnull .I Utfrune
150 b2cfc4e2 2003-09-30 devnull .RI ( utfrrune )
151 b2cfc4e2 2003-09-30 devnull returns a pointer to the first (last)
152 b2cfc4e2 2003-09-30 devnull occurrence of rune
160 b2cfc4e2 2003-09-30 devnull does not occur in the string.
161 b2cfc4e2 2003-09-30 devnull The NUL byte terminating a string is considered to
162 b2cfc4e2 2003-09-30 devnull be part of the string
165 b2cfc4e2 2003-09-30 devnull .I Utfutf
166 b2cfc4e2 2003-09-30 devnull returns a pointer to the first occurrence of
173 b2cfc4e2 2003-09-30 devnull substring of
174 b2cfc4e2 2003-09-30 devnull .IR s1 ,
175 b2cfc4e2 2003-09-30 devnull or 0 if there is none.
178 b2cfc4e2 2003-09-30 devnull is the null string,
179 b2cfc4e2 2003-09-30 devnull .I utfutf
181 b2cfc4e2 2003-09-30 devnull .IR s1 .
182 b2cfc4e2 2003-09-30 devnull .SH HISTORY
183 b2cfc4e2 2003-09-30 devnull These routines were written by Rob Pike and Ken Thompson
184 b2cfc4e2 2003-09-30 devnull and first appeared in Plan 9.
185 b2cfc4e2 2003-09-30 devnull .SH SEE ALSO
186 b2cfc4e2 2003-09-30 devnull .IR utf (7),
187 b2cfc4e2 2003-09-30 devnull .IR tcs (1)