.\" Copyright (C) 2001 Information-technology Promotion Agency (IPA)
.\" Copyright (C) 2001-2009
.\"   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 "Charset" 3m17n "15 Oct 2009" "" "Version 1.5.5" "" "The m17n Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
Charset \- Charset objects and API for them.  

.PP
.SS "Variables: Symbols representing a charset."
Each of the following symbols represents a predefined charset. 
.in +1c
.ti -1c
.RI "\fBMSymbol\fP \fBMcharset_ascii\fP"
.br
.RI "\fISymbol representing the charset ASCII. \fP"
.ti -1c
.RI "\fBMSymbol\fP \fBMcharset_iso_8859_1\fP"
.br
.RI "\fISymbol representing the charset ISO/IEC 8859/1. \fP"
.ti -1c
.RI "\fBMSymbol\fP \fBMcharset_unicode\fP"
.br
.RI "\fISymbol representing the charset Unicode. \fP"
.ti -1c
.RI "\fBMSymbol\fP \fBMcharset_m17n\fP"
.br
.RI "\fISymbol representing the largest charset. \fP"
.ti -1c
.RI "\fBMSymbol\fP \fBMcharset_binary\fP"
.br
.RI "\fISymbol representing the charset for ill-decoded characters. \fP"
.in -1c
.SS "Variables: Parameter keys for mchar_define_charset()."
These are the predefined symbols to use as parameter keys for the function \fBmchar_define_charset()\fP (which see). 
.in +1c
.ti -1c
.RI "\fBMSymbol\fP \fBMmethod\fP"
.br
.ti -1c
.RI "\fBMSymbol\fP \fBMdimension\fP"
.br
.ti -1c
.RI "\fBMSymbol\fP \fBMmin_range\fP"
.br
.ti -1c
.RI "\fBMSymbol\fP \fBMmax_range\fP"
.br
.ti -1c
.RI "\fBMSymbol\fP \fBMmin_code\fP"
.br
.ti -1c
.RI "\fBMSymbol\fP \fBMmax_code\fP"
.br
.ti -1c
.RI "\fBMSymbol\fP \fBMascii_compatible\fP"
.br
.ti -1c
.RI "\fBMSymbol\fP \fBMfinal_byte\fP"
.br
.ti -1c
.RI "\fBMSymbol\fP \fBMrevision\fP"
.br
.ti -1c
.RI "\fBMSymbol\fP \fBMmin_char\fP"
.br
.ti -1c
.RI "\fBMSymbol\fP \fBMmapfile\fP"
.br
.ti -1c
.RI "\fBMSymbol\fP \fBMparents\fP"
.br
.ti -1c
.RI "\fBMSymbol\fP \fBMsubset_offset\fP"
.br
.ti -1c
.RI "\fBMSymbol\fP \fBMdefine_coding\fP"
.br
.ti -1c
.RI "\fBMSymbol\fP \fBMaliases\fP"
.br
.in -1c
.SS "Variables: Symbols representing charset methods."
These are the predefined symbols that can be a value of the \fBMmethod\fP parameter of a charset used in an argument to the \fBmchar_define_charset()\fP function.
.PP
A method specifies how code\-points and character codes are converted. See the documentation of the \fBmchar_define_charset()\fP function for the details. 
.in +1c
.ti -1c
.RI "\fBMSymbol\fP \fBMoffset\fP"
.br
.RI "\fISymbol for the offset type method of charset. \fP"
.ti -1c
.RI "\fBMSymbol\fP \fBMmap\fP"
.br
.RI "\fISymbol for the map type method of charset. \fP"
.ti -1c
.RI "\fBMSymbol\fP \fBMunify\fP"
.br
.RI "\fISymbol for the unify type method of charset. \fP"
.ti -1c
.RI "\fBMSymbol\fP \fBMsubset\fP"
.br
.RI "\fISymbol for the subset type method of charset. \fP"
.ti -1c
.RI "\fBMSymbol\fP \fBMsuperset\fP"
.br
.RI "\fISymbol for the superset type method of charset. \fP"
.in -1c
.SS "Defines"

.in +1c
.ti -1c
.RI "#define \fBMCHAR_INVALID_CODE\fP"
.br
.RI "\fIInvalid code-point. \fP"
.in -1c
.SS "Functions"

.in +1c
.ti -1c
.RI "\fBMSymbol\fP \fBmchar_define_charset\fP (const char *name, \fBMPlist\fP *plist)"
.br
.RI "\fIDefine a charset. \fP"
.ti -1c
.RI "\fBMSymbol\fP \fBmchar_resolve_charset\fP (\fBMSymbol\fP symbol)"
.br
.RI "\fIResolve charset name. \fP"
.ti -1c
.RI "int \fBmchar_list_charset\fP (\fBMSymbol\fP **symbols)"
.br
.RI "\fIList symbols representing charsets. \fP"
.ti -1c
.RI "int \fBmchar_decode\fP (\fBMSymbol\fP charset_name, unsigned code)"
.br
.RI "\fIDecode a code-point. \fP"
.ti -1c
.RI "unsigned \fBmchar_encode\fP (\fBMSymbol\fP charset_name, int c)"
.br
.RI "\fIEncode a character code. \fP"
.ti -1c
.RI "int \fBmchar_map_charset\fP (\fBMSymbol\fP charset_name, void(*func)(int from, int to, void *arg), void *func_arg)"
.br
.RI "\fICall a function for all the characters in a specified charset. \fP"
.in -1c
.SS "Variables"

.in +1c
.ti -1c
.RI "\fBMSymbol\fP \fBMcharset\fP"
.br
.RI "\fIThe symbol \fCMcharset\fP. \fP"
.in -1c
.SH "Detailed Description"
.PP 
Charset objects and API for them. 
.PP
The m17n library uses \fIcharset\fP objects to represent a coded character sets (CCS). The m17n library supports many predefined coded character sets. r, application programs can add other charsets. A character can belong to multiple charsets.
.PP
The m17n library distinguishes the following three concepts:
.PP
.PD 0
.IP "\(bu" 2
A \fIcode\-point\fP is a number assigned by the CCS to each character. Code\-points may or may not be continuous. The type \fCunsigned\fP is used to represent a code\-point. An invalid code\-point is represented by the macro \fCMCHAR_INVALID_CODE\fP.
.PP
.PD 0
.IP "\(bu" 2
A \fIcharacter\fP \fIindex\fP is the canonical index of a character in a CCS. The character that has the character index N occupies the Nth position when all the characters in the current CCS are sorted by their code\-points. Character indices in a CCS are continuous and start with 0.
.PP
.PD 0
.IP "\(bu" 2
A \fIcharacter\fP \fIcode\fP is the internal representation in the m17n library of a character. A character code is a signed integer of 21 bits or longer.
.PP
Each charset object defines how characters are converted between code\-points and character codes. To \fIencode\fP means converting code\-points to character codes and to \fIdecode\fP means converting character codes to code\-points. 
.SH "Define Documentation"
.PP 
.SS "#define MCHAR_INVALID_CODE"
.PP
Invalid code\-point. 
.PP
The macro \fBMCHAR_INVALID_CODE\fP gives the invalid code\-point. 
.SH "Variable Documentation"
.PP 
.SS "\fBMSymbol\fP \fBMcharset_ascii\fP"
.PP
Symbol representing the charset ASCII. 
.PP
The symbol \fBMcharset_ascii\fP has name \fC'ascii'\fP and represents the charset ISO 646, USA Version X3.4\-1968 (ISO\-IR\-6). 
.SS "\fBMSymbol\fP \fBMcharset_iso_8859_1\fP"
.PP
Symbol representing the charset ISO/IEC 8859/1. 
.PP
The symbol \fBMcharset_iso_8859_1\fP has name \fC'iso\-8859\-1'\fP and represents the charset ISO/IEC 8859\-1:1998. 
.SS "\fBMSymbol\fP \fBMcharset_unicode\fP"
.PP
Symbol representing the charset Unicode. 
.PP
The symbol \fBMcharset_unicode\fP has name \fC'unicode'\fP and represents the charset Unicode. 
.SS "\fBMSymbol\fP \fBMcharset_m17n\fP"
.PP
Symbol representing the largest charset. 
.PP
The symbol \fBMcharset_m17n\fP has name \fC'm17n'\fP and represents the charset that contains all characters supported by the m17n library. 
.SS "\fBMSymbol\fP \fBMcharset_binary\fP"
.PP
Symbol representing the charset for ill\-decoded characters. 
.PP
The symbol \fBMcharset_binary\fP has name \fC'binary'\fP and represents the fake charset which the decoding functions put to an M\-text as a text property when they encounter an invalid byte (sequence).
.PP
See \fBCode Conversion\fP for more details. 
.SS "\fBMSymbol\fP \fBMmethod\fP"
.PP
.SS "\fBMSymbol\fP \fBMdimension\fP"
.PP
.SS "\fBMSymbol\fP \fBMmin_range\fP"
.PP
.SS "\fBMSymbol\fP \fBMmax_range\fP"
.PP
.SS "\fBMSymbol\fP \fBMmin_code\fP"
.PP
.SS "\fBMSymbol\fP \fBMmax_code\fP"
.PP
.SS "\fBMSymbol\fP \fBMascii_compatible\fP"
.PP
.SS "\fBMSymbol\fP \fBMfinal_byte\fP"
.PP
.SS "\fBMSymbol\fP \fBMrevision\fP"
.PP
.SS "\fBMSymbol\fP \fBMmin_char\fP"
.PP
.SS "\fBMSymbol\fP \fBMmapfile\fP"
.PP
.SS "\fBMSymbol\fP \fBMparents\fP"
.PP
.SS "\fBMSymbol\fP \fBMsubset_offset\fP"
.PP
.SS "\fBMSymbol\fP \fBMdefine_coding\fP"
.PP
.SS "\fBMSymbol\fP \fBMaliases\fP"
.PP
.SS "\fBMSymbol\fP \fBMoffset\fP"
.PP
Symbol for the offset type method of charset. 
.PP
The symbol \fBMoffset\fP has the name \fC'offset'\fP and, when used as a value of \fBMmethod\fP parameter of a charset, it means that the conversion of code\-points and character codes of the charset is done by this calculation:
.PP
.PP
.nf

CHARACTER\-CODE = CODE\-POINT \- MIN\-CODE + MIN\-CHAR
.fi
.PP
.PP
where, MIN\-CODE is a value of \fBMmin_code\fP parameter of the charset, and MIN\-CHAR is a value of \fBMmin_char\fP parameter. 
.SS "\fBMSymbol\fP \fBMmap\fP"
.PP
Symbol for the map type method of charset. 
.PP
The symbol \fBMmap\fP has the name \fC'map'\fP and, when used as a value of \fBMmethod\fP parameter of a charset, it means that the conversion of code\-points and character codes of the charset is done by map looking up. The map must be given by \fBMmapfile\fP parameter. 
.SS "\fBMSymbol\fP \fBMunify\fP"
.PP
Symbol for the unify type method of charset. 
.PP
The symbol \fBMunify\fP has the name \fC'unify'\fP and, when used as a value of \fBMmethod\fP parameter of a charset, it means that the conversion of code\-points and character codes of the charset is done by map looking up and offsetting. The map must be given by \fBMmapfile\fP parameter. For this kind of charset, a unique continuous character code space for all characters is assigned.
.PP
If the map has an entry for a code\-point, the conversion is done by looking up the map. Otherwise, the conversion is done by this calculation:
.PP
.PP
.nf

CHARACTER\-CODE = CODE\-POINT \- MIN\-CODE + LOWEST\-CHAR\-CODE
.fi
.PP
.PP
where, MIN\-CODE is a value of \fBMmin_code\fP parameter of the charset, and LOWEST\-CHAR\-CODE is the lowest character code of the assigned code space. 
.SS "\fBMSymbol\fP \fBMsubset\fP"
.PP
Symbol for the subset type method of charset. 
.PP
The symbol \fBMsubset\fP has the name \fC'subset'\fP and, when used as a value of \fBMmethod\fP parameter of a charset, it means that the charset is a subset of a parent charset. The parent charset must be given by \fBMparents\fP parameter. The conversion of code\-points and character codes of the charset is done conceptually by this calculation:
.PP
.PP
.nf

CHARACTER\-CODE = PARENT\-CODE (CODE\-POINT) + SUBSET\-OFFSET
.fi
.PP
.PP
where, PARENT\-CODE is a pseudo function that returns a character code of CODE\-POINT in the parent charset, and SUBSET\-OFFSET is a value given by \fBMsubset_offset\fP parameter. 
.SS "\fBMSymbol\fP \fBMsuperset\fP"
.PP
Symbol for the superset type method of charset. 
.PP
The symbol \fBMsuperset\fP has the name \fC'superset'\fP and, when used as a value of \fBMmethod\fP parameter of a charset, it means that the charset is a superset of parent charsets. The parent charsets must be given by \fBMparents\fP parameter. 
.SS "\fBMSymbol\fP \fBMcharset\fP"
.PP
The symbol \fCMcharset\fP. 
.PP
Any decoded M\-text has a text property whose key is the predefined symbol \fCMcharset\fP. The name of \fCMcharset\fP is \fC'charset'\fP. 
.SH COPYRIGHT
Copyright (C) 2001 Information\-technology Promotion Agency (IPA)
.br
Copyright (C) 2001\-2009 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>.
