m17nConv(3m17n)
πΈ NAME πΈ
m17nConv β that's this page, from the m17nConv(3m17n) manual of The m17n Library π β and its full name entry is m17nConv_-_Code_Conver. What it's about: coding system objects and API for them. Periodt. β¨
π SYNOPSIS π
okay so this is the whole cast list before the show even starts. no cap, it's a lot, but every single one of them is important. π«Ά
π¦ Data Structures π¦
struct MConverterβ the structure to be used in code conversion. your main character, honestly. πstruct MCodingInfoISO2022β the structure for a coding system of typeMCODING_TYPE_ISO_2022.struct MCodingInfoUTFβ the structure for extra information about a coding system of typeMCODING_TYPE_UTF.
β¨ Enumerations β¨
enum MConversionResultβ codes that represent the result of code conversion. the members are:
enum MConversionResult {
MCONVERSION_RESULT_SUCCESS,
MCONVERSION_RESULT_INVALID_BYTE,
MCONVERSION_RESULT_INVALID_CHAR,
MCONVERSION_RESULT_INSUFFICIENT_SRC,
MCONVERSION_RESULT_INSUFFICIENT_DST,
MCONVERSION_RESULT_IO_ERROR
}
enum MCodingTypeβ types of coding system. it's giving taxonomy, it's giving categories:
enum MCodingType {
MCODING_TYPE_CHARSET,
MCODING_TYPE_UTF,
MCODING_TYPE_ISO_2022,
MCODING_TYPE_MISC
}
enum MCodingFlagISO2022β bit-masks to specify the detail of coding system whose type isMCODING_TYPE_ISO_2022. bestie, look at these hex values, they ate π
enum MCodingFlagISO2022 {
MCODING_ISO_RESET_AT_EOL = 0x1,
MCODING_ISO_RESET_AT_CNTL = 0x2,
MCODING_ISO_EIGHT_BIT = 0x4,
MCODING_ISO_LONG_FORM = 0x8,
MCODING_ISO_DESIGNATION_G0 = 0x10,
MCODING_ISO_DESIGNATION_G1 = 0x20,
MCODING_ISO_DESIGNATION_CTEXT = 0x40,
MCODING_ISO_DESIGNATION_CTEXT_EXT = 0x80,
MCODING_ISO_LOCKING_SHIFT = 0x100,
MCODING_ISO_SINGLE_SHIFT = 0x200,
MCODING_ISO_SINGLE_SHIFT_7 = 0x400,
MCODING_ISO_EUC_TW_SHIFT = 0x800,
MCODING_ISO_ISO6429 = 0x1000,
MCODING_ISO_REVISION_NUMBER = 0x2000,
MCODING_ISO_FULL_SUPPORT = 0x3000,
MCODING_ISO_FLAG_MAX
}
π₯ Functions π₯
every single one of these, no skipping, that's the rule:
MSymbol mconv_define_coding (const char *name, MPlist *plist, int(*resetter)(MConverter *), int(*decoder)(const unsigned char *, int, MText *, MConverter *), int(*encoder)(MText *, int, int, unsigned char *, int, MConverter *), void *extra_info)MSymbol mconv_resolve_coding (MSymbol symbol)β resolve coding system name.int mconv_list_codings (MSymbol **symbols)β list symbols representing coding systems.MConverter * mconv_buffer_converter (MSymbol name, const unsigned char *buf, int n)β create a code converter bound to a buffer.MConverter * mconv_stream_converter (MSymbol name, FILE *fp)β create a code converter bound to a stream.int mconv_reset_converter (MConverter *converter)β reset a code converter.void mconv_free_converter (MConverter *converter)β free a code converter.MConverter * mconv_rebind_buffer (MConverter *converter, const unsigned char *buf, int n)β bind a buffer to a code converter.MConverter * mconv_rebind_stream (MConverter *converter, FILE *fp)β bind a stream to a code converter.MText * mconv_decode (MConverter *converter, MText *mt)β decode a byte sequence into an M-text.MText * mconv_decode_buffer (MSymbol name, const unsigned char *buf, int n)β decode a buffer area based on a coding system.MText * mconv_decode_stream (MSymbol name, FILE *fp)β decode a stream input based on a coding system.int mconv_encode (MConverter *converter, MText *mt)β encode an M-text into a byte sequence.int mconv_encode_range (MConverter *converter, MText *mt, int from, int to)β encode a part of an M-text.int mconv_encode_buffer (MSymbol name, MText *mt, unsigned char *buf, int n)β encode an M-text into a buffer area.int mconv_encode_stream (MSymbol name, MText *mt, FILE *fp)β encode an M-text to write to a stream.int mconv_getc (MConverter *converter)β read a character via a code converter.int mconv_ungetc (MConverter *converter, int c)β push a character back to a code converter.int mconv_putc (MConverter *converter, int c)β write a character via a code converter.MText * mconv_gets (MConverter *converter, MText *mt)β read a line using a code converter.
π Variables: Symbols representing coding systems π
these are the icons, the pre-made coding systems, already loaded and ready to slay:
MSymbol Mcoding_us_asciiβ symbol for the coding system US-ASCII.MSymbol Mcoding_iso_8859_1β symbol for the coding system ISO-8859-1.MSymbol Mcoding_utf_8β symbol for the coding system UTF-8.MSymbol Mcoding_utf_8_fullβ symbol for the coding system UTF-8-FULL.MSymbol Mcoding_utf_16β symbol for the coding system UTF-16.MSymbol Mcoding_utf_16beβ symbol for the coding system UTF-16BE.MSymbol Mcoding_utf_16leβ symbol for the coding system UTF-16LE.MSymbol Mcoding_utf_32β symbol for the coding system UTF-32.MSymbol Mcoding_utf_32beβ symbol for the coding system UTF-32BE.MSymbol Mcoding_utf_32leβ symbol for the coding system UTF-32LE.MSymbol Mcoding_sjisβ symbol for the coding system SJIS.
π Variables: Parameter keys for mconv_define_coding(). π
the little keys you hand over when you're defining your own coding system:
MSymbol MtypeMSymbol McharsetsMSymbol MflagsMSymbol MdesignationMSymbol MinvocationMSymbol Mcode_unitMSymbol MbomMSymbol Mlittle_endian
β Variables: Symbols representing coding system types. β
MSymbol MutfMSymbol Miso_2022
π§ Variables: Symbols appearing in the value of Mflags parameter. π§
symbols that can be a value of the Mflags parameter of a coding system used in an argument to the mconv_define_coding() function (which see).
MSymbol Mreset_at_eolMSymbol Mreset_at_cntlMSymbol Meight_bitMSymbol Mlong_formMSymbol Mdesignation_g0MSymbol Mdesignation_g1MSymbol Mdesignation_ctextMSymbol Mdesignation_ctext_extMSymbol Mlocking_shiftMSymbol Msingle_shiftMSymbol Msingle_shift_7MSymbol Meuc_tw_shiftMSymbol Miso_6429MSymbol Mrevision_numberMSymbol Mfull_support
π Variables: Others π
the remaining variables. the stragglers. we love them anyway. π₯Ί
MSymbol Mmaybeβ symbol whose name is 'maybe'.MSymbol Mcodingβ the symbolMcoding.
π Detailed Description π
Coding system objects and API for them. That's the vibe, that's the whole thesis. π
The m17n library represents a character encoding scheme (CES) of coded character sets (CCS) as an object called a coding system. And here's the fun part bestie β application programs can add original coding systems. yes, you can make your own. iconic behavior. β¨
To encode means converting code-points to character codes, and to decode means converting character codes back to code-points. it's a two-way street, it's giving mutual. π
Application programs can decode a byte sequence with a specified coding system into an M-text, and inversely, can encode an M-text into a byte sequence. that's the whole relationship, no cap. π¦
π Data Structure Documentation π
π§ MConverter π§
Structure to be used in code conversion. okay so this is the main character of code conversion structs π
β¨ FIELD DOCUMENTATION β¨
int MConverter::lenientβ set this to nonzero if the conversion should be lenient. By default, conversion is strict (i.e. not lenient).
If strict: the converter stops at the first invalid byte (on decoding) or at the first character not supported by the coding system (on encoding). When that happens, MConverter->result is set to MCONVERSION_RESULT_INVALID_BYTE or MCONVERSION_RESULT_INVALID_CHAR accordingly.
If lenient: on decoding, an invalid byte is kept per se; on encoding, an invalid character is replaced with '<U+XXXX>' (if the character is a Unicode character) or with '<M+XXXXXX>' (otherwise). bestie that's the vibe.
int MConverter::last_blockβ set to nonzero before decoding or encoding the last block of the byte sequence or the character sequence respectively. The value influences conversion as below.- On decoding, when the last few bytes are too short to form a valid byte sequence:
- If nonzero: conversion terminates by error (
MCONVERSION_RESULT_INVALID_BYTE) at the first byte of the sequence. - If zero: conversion terminates successfully. Those bytes are stored in the converter as carryover and are prepended to the byte sequence of the further conversion.
- If nonzero: conversion terminates by error (
- On encoding, when the coding system is context dependent:
- If nonzero: conversion may produce a byte sequence at the end to reset the context to the initial state even if the source characters are zero.
- If zero: conversion never produce such a byte sequence at the end.
- On decoding, when the last few bytes are too short to form a valid byte sequence:
unsigned MConverter::at_mostβ if nonzero, it specifies at most how many characters to convert.int MConverter::ncharsβ the following three members are to report the result of the conversion. Number of characters most recently decoded or encoded.int MConverter::nbytesβ number of bytes recently decoded or encoded.enum MConversionResult MConverter::resultβ result code of the conversion.void* MConverter::ptrβ no extra description, just a pointer.double MConverter::dblβ no extra description, just a double.char MConverter::c[256]β no extra description, just a 256-char array.union { ... } MConverter::statusβ various information about the status of code conversion. The contents depend on the type of coding system. It is assured thatstatusis aligned so that any type of casting is safe and at least 256 bytes of memory space can be used. iykykvoid* MConverter::internal_infoβ this member is for internally use only. An application program should never touch it. π
πΈ MCodingInfoISO2022 πΈ
Structure for a coding system of type MCODING_TYPE_ISO_2022. slay
β¨ FIELD DOCUMENTATION β¨
int MCodingInfoISO2022::initial_invocation[2]β table of numbers of an ISO2022 code extension element invoked to each graphic plane (Graphic Left and Graphic Right).-1means no code extension element is invoked to that plane.char MCodingInfoISO2022::designations[32]β table of code extension elements. The Nth element corresponds to the Nth charset incharset_names, which is an argument given to themconv_define_coding()function.- If an element value is
0..3, it specifies a graphic register number to designate the corresponds charset. In addition, the charset is initially designated to that graphic register. - If the value is
-4..-1, it specifies a graphic register number0..3respectively to designate the corresponds charset. Initially, the charset is not designated to any graphic register.
- If an element value is
unsigned MCodingInfoISO2022::flagsβ bitwise OR ofenum MCodingFlagISO2022. periodt
π¦ MCodingInfoUTF π¦
Structure for extra information about a coding system of type MCODING_TYPE_UTF. it's giving UTF energy
β¨ FIELD DOCUMENTATION β¨
int MCodingInfoUTF::code_unit_bitsβ specify bits of a code unit. The value must be8,16, or32.int MCodingInfoUTF::bomβ specify how to handle the heading BOM (byte order mark). The value must be0,1, or2. The meanings are as follows:0: On decoding, check the first two byte. If they are BOM, decide endian by them. If not, decide endian by the memberendian. On encoding, produce byte sequence according toendianwith heading BOM.1: On decoding, do not handle the first two bytes as BOM, and decide endian byendian. On encoding, produce byte sequence according toendianwithout BOM.2: On decoding, handle the first two bytes as BOM and decide endian by them. On encoding, produce byte sequence according toendianwith heading BOM.
If <code_unit_bits> is 8, the value has no meaning. not me forgetting that
int MCodingInfoUTF::endianβ specify the endian type. The value must be0or1.0means little endian, and1means big endian.
If <code_unit_bits> is 8, the value has no meaning.
π Enumeration Type Documentation π
π₯ enum MConversionResult π₯
Codes that represent the result of code conversion. One of these values is set in MConverter->result.
Enumerator
MCONVERSION_RESULT_SUCCESSβ code conversion is successful. we love a success storyMCONVERSION_RESULT_INVALID_BYTEβ on decoding, the source contains an invalid byte.MCONVERSION_RESULT_INVALID_CHARβ on encoding, the source contains a character that cannot be encoded by the specified coding system.MCONVERSION_RESULT_INSUFFICIENT_SRCβ on decoding, the source ends with an incomplete byte sequence.MCONVERSION_RESULT_INSUFFICIENT_DSTβ on encoding, the destination is too short to store the result.MCONVERSION_RESULT_IO_ERRORβ an I/O error occurred in the conversion.
π enum MCodingType π
Types of coding system.
Enumerator
MCODING_TYPE_CHARSETβ a coding system of this type supports charsets directly. The dimension of each charset defines the length of bytes to represent a single character of the charset, and a byte sequence directly represents the code-point of a character. The m17n library provides the default decoding and encoding routines of this type.MCODING_TYPE_UTFβ a coding system of this type supports byte sequences of a UTF (UTF-8, UTF-16, UTF-32) like structure. The m17n library provides the default decoding and encoding routines of this type.MCODING_TYPE_ISO_2022β a coding system of this type supports byte sequences of an ISO-2022 like structure. The details of each structure are specified byMCodingInfoISO2022. The m17n library provides decoding and encoding routines of this type.MCODING_TYPE_MISCβ a coding system of this type is for byte sequences of miscellaneous structures. The m17n library does not provide decoding and encoding routines of this type. They must be provided by the application program.
π enum MCodingFlagISO2022 π
Bit-masks to specify the detail of coding system whose type is MCODING_TYPE_ISO_2022.
Enumerator
MCODING_ISO_RESET_AT_EOLβ on encoding, reset the invocation and designation status to initial at end of line.MCODING_ISO_RESET_AT_CNTLβ on encoding, reset the invocation and designation status to initial before any control codes.MCODING_ISO_EIGHT_BITβ use the right graphic plane.MCODING_ISO_LONG_FORMβ use the non-standard 4 bytes format for designation sequence for charsets JISX0208-1978, GB2312, and JISX0208-1983.MCODING_ISO_DESIGNATION_G0β on encoding, unless explicitly specified, designate charsets to G0.MCODING_ISO_DESIGNATION_G1β on encoding, unless explicitly specified, designate charsets except for ASCII to G1.MCODING_ISO_DESIGNATION_CTEXTβ on encoding, unless explicitly specified, designate 94-chars charsets to G0, 96-chars charsets to G1.MCODING_ISO_DESIGNATION_CTEXT_EXTβ on encoding, encode such charsets not conforming to ISO-2022 byESC % / ..., and encode non-supported Unicode characters byESC % G ... ESC % @. On decoding, handle those escape sequences.MCODING_ISO_LOCKING_SHIFTβ use locking shift.MCODING_ISO_SINGLE_SHIFTβ use single shift (SS2 (0x8EorESC N), SS3 (0x8ForESC O)).MCODING_ISO_SINGLE_SHIFT_7β use 7-bit single shift 2 (SS2 (0x19)).MCODING_ISO_EUC_TW_SHIFTβ use EUC-TW like special shifting.MCODING_ISO_ISO6429β use ISO-6429 escape sequences to indicate direction. Not yet implemented.MCODING_ISO_REVISION_NUMBERβ on encoding, if a charset has revision number, produce escape sequences to specify the number.MCODING_ISO_FULL_SUPPORTβ support all ISO-2022 charsets.MCODING_ISO_FLAG_MAXβ no description in the source, just the max flag.
β¨ Variable Documentation β¨
Okay bestie, gather round. These are all the global variable symbols the m17n library is serving. Every single one, no cap. π
MSymbol Mcoding_us_asciiβ Symbol for the coding system US-ASCII. The symbolMcoding_us_asciihas name'us-ascii'and represents a coding system for the CES US-ASCII. πMSymbol Mcoding_iso_8859_1β Symbol for the coding system ISO-8859-1. The symbolMcoding_iso_8859_1has name'iso-8859-1'and represents a coding system for the CES ISO-8859-1. πMSymbol Mcoding_utf_8β Symbol for the coding system UTF-8. The symbolMcoding_utf_8has name'utf-8'and represents a coding system for the CES UTF-8. β¨MSymbol Mcoding_utf_8_fullβ Symbol for the coding system UTF-8-FULL. The symbolMcoding_utf_8_fullhas name'utf-8-full'and represents a coding system that is a extension of UTF-8. This coding system uses the same encoding algorithm as UTF-8 but is not limited to the Unicode characters. It can encode all characters supported by the m17n library. π₯MSymbol Mcoding_utf_16β Symbol for the coding system UTF-16. The symbolMcoding_utf_16has name'utf-16'and represents a coding system for the CES UTF-16 (RFC 2279). πMSymbol Mcoding_utf_16beβ Symbol for the coding system UTF-16BE. The symbolMcoding_utf_16behas name'utf-16be'and represents a coding system for the CES UTF-16BE (RFC 2279). π¦MSymbol Mcoding_utf_16leβ Symbol for the coding system UTF-16LE. The symbolMcoding_utf_16lehas name'utf-16le'and represents a coding system for the CES UTF-16LE (RFC 2279). πΈMSymbol Mcoding_utf_32β Symbol for the coding system UTF-32. The symbolMcoding_utf_32has name'utf-32'and represents a coding system for the CES UTF-32 (RFC 2279). πMSymbol Mcoding_utf_32beβ Symbol for the coding system UTF-32BE. The symbolMcoding_utf_32behas name'utf-32be'and represents a coding system for the CES UTF-32BE (RFC 2279). βMSymbol Mcoding_utf_32leβ Symbol for the coding system UTF-32LE. The symbolMcoding_utf_32lehas name'utf-32le'and represents a coding system for the CES UTF-32LE (RFC 2279). πMSymbol Mcoding_sjisβ Symbol for the coding system SJIS. The symbolMcoding_sjishas name'sjis'and represents a coding system for the CES Shift-JIS. πMSymbol Mtypeβ Parameter key formconv_define_coding()(which see). π
And here's the next clique of symbols, straight from the original with no extra description attached:
MSymbol McharsetsMSymbol MflagsMSymbol MdesignationMSymbol MinvocationMSymbol Mcode_unitMSymbol MbomMSymbol Mlittle_endianMSymbol Mutfβ Symbol that can be a value of theMtypeparameter of a coding system used in an argument to themconv_define_coding()function (which see). π«Ά
Then this whole squad, also just vibing as symbols in the original:
MSymbol Miso_2022MSymbol Mreset_at_eolMSymbol Mreset_at_cntlMSymbol Meight_bitMSymbol Mlong_formMSymbol Mdesignation_g0MSymbol Mdesignation_g1MSymbol Mdesignation_ctextMSymbol Mdesignation_ctext_extMSymbol Mlocking_shiftMSymbol Msingle_shiftMSymbol Msingle_shift_7MSymbol Meuc_tw_shiftMSymbol Miso_6429MSymbol Mrevision_numberMSymbol Mfull_supportMSymbol Mmaybeβ Symbol whose name is'maybe'. The variableMmaybeis a symbol of name'maybe'. It is used a value ofMbomparameter of the functionmconv_define_coding()(which see). π
And finally, the main character herself:
MSymbol Mcodingβ The symbolMcoding. Any decoded M-text has a text property whose key is the predefined symbolMcoding. The name ofMcodingis'coding'. π
π Author π
Generated automatically by Doxygen for The m17n Library from the source code. π (The robots did this one, but we're making it cute.)
π COPYRIGHT π
Copyright (C) 2001 Information-technology Promotion Agency (IPA) Copyright (C) 2001-2011 National Institute of Advanced Industrial Science and Technology (AIST)
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>.
Version 1.8.4, dated Mon Sep 25 2023, from m17nConv(3m17n) β byeee bestie, mwah ππβ¨
π¦ where this page comes from
- debian trixie: m17n-docs 1.8.4-1
- ubuntu noble: m17n-docs 1.8.4-1
- ubuntu questing: m17n-docs 1.8.4-1
- ubuntu resolute: m17n-docs 1.8.4-1build1
- ubuntu stonking: m17n-docs 1.8.4-1build1
- Copyright (C) 2001 Information-technology Promotion Agency (IPA)
- Copyright (C) 2001-2011 National Institute of Advanced Industrial Science and Technology (AIST)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms