1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466
|
.\" Copyright (C) 2001 Information-technology Promotion Agency (IPA)
.\" Copyright (C) 2001-2011
.\" National Institute of Advanced Industrial Science and Technology (AIST)
.\" This file is part of the m17n library documentation.
.\" Permission is granted to copy, distribute and/or modify this document
.\" under the terms of the GNU Free Documentation License, Version 1.2 or
.\" any later version published by the Free Software Foundation; with no
.\" Invariant Section, no Front-Cover Texts,
.\" and no Back-Cover Texts. A copy of the license is included in the
.\" appendix entitled "GNU Free Documentation License".
.TH "mconv_define_coding" 3m17n "12 Jan 2011" "Version 1.6.2" "The m17n Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
mconv_define_coding \- Define a coding system.
.SH SYNOPSIS
\fBMSymbol\fP
\fBmconv_define_coding\fP (const char *
\fIname\fP, \fBMPlist\fP *
\fIplist\fP, int(*)(\fBMConverter\fP *)
\fIresetter\fP, int(*)(const unsigned char *,
\fIint\fP, \fBMText\fP *, \fBMConverter\fP *)
\fIdecoder\fP, int(*)(\fBMText\fP *,
\fIint\fP,
\fIint\fP, unsigned char *,
\fIint\fP, \fBMConverter\fP *)
\fIencoder\fP, void *
\fIextra_info\fP)
.SH DESCRIPTION
Define a coding system. The
.ft B
mconv_define_coding()
.ft R
function defines a new coding system and makes it accessible via a symbol whose name is
.ft B
name\fP.
.ft R
.ft B
plist
.ft R
specifies parameters of the coding system as below:
.PP
.PD 0
.IP "\(bu" 2
Key is
.ft C
Mtype\fP,
.ft R
value is a symbol
.PP
The value specifies the type of the coding system. It must be
.ft B
Mcharset\fP,
.ft R
.ft B
Mutf\fP,
.ft R
.ft B
Miso_2022\fP,
.ft R
or
.ft B
Mnil\fP.
.ft R
.PP
If the type is
.ft B
Mcharset\fP,
.ft R
.ft B
extra_info
.ft R
is ignored.
.PP
If the type is
.ft B
Mutf\fP,
.ft R
.ft B
extra_info
.ft R
must be a pointer to
.ft B
MCodingInfoUTF\fP.
.ft R
.PP
If the type is
.ft B
Miso_2022\fP,
.ft R
.ft B
extra_info
.ft R
must be a pointer to
.ft B
MCodingInfoISO2022\fP.
.ft R
.PP
If the type is
.ft B
Mnil\fP,
.ft R
the argument
.ft B
resetter\fP,
.ft R
.ft B
decoder\fP,
.ft R
and
.ft B
encoder
.ft R
must be supplied.
.ft B
extra_info
.ft R
is ignored. Otherwise, they can be
.ft C
NULL
.ft R
and the m17n library provides proper defaults.
.PP
.IP "\(bu" 2
Key is
.ft B
Mcharsets\fP,
.ft R
value is a plist
.PP
The value specifies a list charsets supported by the coding system. The keys of the plist must be
.ft B
Msymbol\fP,
.ft R
and the values must be symbols representing charsets.
.PP
.IP "\(bu" 2
Key is
.ft B
Mflags\fP,
.ft R
value is a plist
.PP
If the type is
.ft B
Miso_2022\fP,
.ft R
the values specifies flags to control the ISO 2022 interpreter. The keys of the plist must e
.ft B
Msymbol\fP,
.ft R
and values must be one of the following.
.PP
.PD 0
.IP " \(bu" 4
\fBMreset_at_eol
.ft R
.PP
If this flag exists, designation and invocation status is reset to the initial state at the end of line.
.PP
.IP " \(bu" 4
\fBMreset_at_cntl
.ft R
.PP
If this flag exists, designation and invocation status is reset to the initial state at a control character.
.PP
.IP " \(bu" 4
\fBMeight_bit
.ft R
.PP
If this flag exists, the graphic plane right is used.
.PP
.IP " \(bu" 4
\fBMlong_form
.ft R
.PP
If this flag exists, the over\-long escape sequences (ESC '$' '(' <final_byte>) are used for designating the CCS JISX0208.1978, GB2312, and JISX0208.
.PP
.IP " \(bu" 4
\fBMdesignation_g0
.ft R
.PP
If this flag and
.ft B
Mfull_support
.ft R
exists, designates charsets not listed in the charset list to the graphic register G0.
.PP
.IP " \(bu" 4
\fBMdesignation_g1
.ft R
.PP
If this flag and
.ft B
Mfull_support
.ft R
exists, designates charsets not listed in the charset list to the graphic register G1.
.PP
.IP " \(bu" 4
\fBMdesignation_ctext
.ft R
.PP
If this flag and
.ft B
Mfull_support
.ft R
exists, designates charsets not listed in the charset list to a graphic register G0 or G1 based on the criteria of the Compound Text.
.PP
.IP " \(bu" 4
\fBMdesignation_ctext_ext
.ft R
.PP
If this flag and
.ft B
Mfull_support
.ft R
exists, designates charsets not listed in the charset list to a graphic register G0 or G1, or use extended segment for such charsets based on the criteria of the Compound Text.
.PP
.IP " \(bu" 4
\fBMlocking_shift
.ft R
.PP
If this flag exists, use locking shift.
.PP
.IP " \(bu" 4
\fBMsingle_shift
.ft R
.PP
If this flag exists, use single shift.
.PP
.IP " \(bu" 4
\fBMsingle_shift_7
.ft R
.PP
If this flag exists, use 7\-bit single shift code (0x19).
.PP
.IP " \(bu" 4
\fBMeuc_tw_shift
.ft R
.PP
If this flag exists, use a special shifting according to EUC\-TW.
.PP
.IP " \(bu" 4
\fBMiso_6429
.ft R
.PP
This flag is currently ignored.
.PP
.IP " \(bu" 4
\fBMrevision_number
.ft R
.PP
If this flag exists, use a revision number escape sequence to designate a charset that has a revision number.
.PP
.IP " \(bu" 4
\fBMfull_support
.ft R
.PP
If this flag exists, support all charsets registered in the International Registry.
.PP
.PP
.PP
.IP "\(bu" 2
Key is
.ft B
Mdesignation\fP,
.ft R
value is a plist
.PP
If the type is
.ft B
Miso_2022\fP,
.ft R
the value specifies how to designate each supported characters. The keys of the plist must be
.ft B
Minteger\fP,
.ft R
and the values must be numbers indicating a graphic registers. The Nth element value is for the Nth charset of the charset list. The value 0..3 means that it is assumed that a charset is already designated to the graphic register 0..3. The negative value G (\-4..\-1) means that a charset is not designated to any register at first, and if necessary, is designated to the (G+4) graphic register.
.PP
.IP "\(bu" 2
Key is
.ft B
Minvocation\fP,
.ft R
value is a plist
.PP
If the type is
.ft B
Miso_2022\fP,
.ft R
the value specifies how to invocate each graphic registers. The plist length must be one or two. The keys of the plist must be
.ft B
Minteger\fP,
.ft R
and the values must be numbers indicating a graphic register. The value of the first element specifies which graphic register is invocated to the graphic plane left. If the length is one, no graphic register is invocated to the graphic plane right. Otherwise, the value of the second element specifies which graphic register is invocated to the graphic plane right.
.PP
.IP "\(bu" 2
Key is
.ft B
Mcode_unit\fP,
.ft R
value is an integer
.PP
If the type is
.ft B
Mutf\fP,
.ft R
the value specifies the bit length of a code\-unit. It must be 8, 16, or 32.
.PP
.IP "\(bu" 2
Key is
.ft B
Mbom\fP,
.ft R
value is a symbol
.PP
If the type is
.ft B
Mutf
.ft R
and the code\-unit bit length is 16 or 32, it specifies whether or not to use BOM (Byte Order Mark). If the value is
.ft B
Mnil
.ft R
(default), BOM is not used, else if the value is
.ft B
Mmaybe\fP,
.ft R
the existence of BOM is detected at decoding time, else BOM is used.
.PP
.IP "\(bu" 2
Key is
.ft B
Mlittle_endian\fP,
.ft R
value is a symbol
.PP
If the type is
.ft B
Mutf
.ft R
and the code\-unit bit length is 16 or 32, it specifies whether or not the encoding is little endian. If the value is
.ft B
Mnil
.ft R
(default), it is big endian, else it is little endian.
.PP
.PP
.PP
\fBresetter
.ft R
is a pointer to a function that resets a converter for the coding system to the initial status. The pointed function is called with one argument, a pointer to a converter object.
.PP
\fBdecoder
.ft R
is a pointer to a function that decodes a byte sequence according to the coding system. The pointed function is called with four arguments:
.PP
.PD 0
.IP "\(bu" 2
A pointer to the byte sequence to decode.
.IP "\(bu" 2
The number of bytes to decode.
.IP "\(bu" 2
A pointer to an M\-text to which the decoded characters are appended.
.IP "\(bu" 2
A pointer to a converter object.
.PP
\fBdecoder
.ft R
must return 0 if it succeeds. Otherwise it must return \-1.
.PP
\fBencoder
.ft R
is a pointer to a function that encodes an M\-text according to the coding system. The pointed function is called with six arguments:
.PP
.PD 0
.IP "\(bu" 2
A pointer to the M\-text to encode.
.IP "\(bu" 2
The starting position of the encoding.
.IP "\(bu" 2
The ending position of the encoding.
.IP "\(bu" 2
A pointer to a memory area where the produced bytes are stored.
.IP "\(bu" 2
The size of the memory area.
.IP "\(bu" 2
A pointer to a converter object.
.PP
\fBencoder
.ft R
must return 0 if it succeeds. Otherwise it must return \-1.
.PP
\fBextra_info
.ft R
is a pointer to a data structure that contains extra information about the coding system. The type of the data structure depends on
.ft B
type\fP.
.ft R
.PP
.SH RETURN VALUE
.PP
.RS 4
.RE
.PP
If the operation was successful,
.ft B
mconv_define_coding()
.ft R
returns a symbol whose name is
.ft B
name\fP.
.ft R
If an error is detected, it returns
.ft B
Mnil
.ft R
and assigns an error code to the external variable
.ft B
merror_code\fP.
.ft R
.PP
.SH ERRORS
.PP
.RS 4
\fCMERROR_CODING
.ft R
.RE
.PP
.SH COPYRIGHT
Copyright (C) 2001 Information\-technology Promotion Agency (IPA)
.br
Copyright (C) 2001\-2011 National Institute of Advanced Industrial Science and Technology (AIST)
.br
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License
<http://www.gnu.org/licenses/fdl.html>.
|