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