---
name: "m17nMtext"
section: "3m17n"
platform: "linux"
package: "m17n-docs"
version: "1.8.4-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/m17nMtext"
---

# m17nMtext(3m17n)

\- M-text objects and API for them.

## NAME

m17nMtext\_-\_M- -  - M-text objects and API for them.

## SYNOPSIS

### Enumerations

enum **MTextFormat** { **MTEXT\_FORMAT\_US\_ASCII**, **MTEXT\_FORMAT\_UTF\_8**, **MTEXT\_FORMAT\_UTF\_16LE**, **MTEXT\_FORMAT\_UTF\_16BE**, **MTEXT\_FORMAT\_UTF\_32LE**, **MTEXT\_FORMAT\_UTF\_32BE**, **MTEXT\_FORMAT\_MAX** }\
 Enumeration for specifying the format of an M-text.  enum **MTextLineBreakOption** { **MTEXT\_LBO\_SP\_CM** = 1, **MTEXT\_LBO\_KOREAN\_SP** = 2, **MTEXT\_LBO\_AI\_AS\_ID** = 4, **MTEXT\_LBO\_MAX** }\
 Enumeration for specifying a set of line breaking option.

### Functions

int **mtext\_line\_break** (**MText** \*mt, int pos, int option, int \*after)\
 Find a linebreak postion of an M-text.  **MText** \* **mtext** ()\
 Allocate a new M-text.  **MText** \* **mtext\_from\_data** (const void \*data, int nitems, enum **MTextFormat** format)\
 Allocate a new M-text with specified data.  void \* **mtext\_data** (**MText** \*mt, enum **MTextFormat** \*fmt, int \*nunits, int \*pos\_idx, int \*unit\_idx)\
 Get information about the text data in M-text.  int **mtext\_len** (**MText** \*mt)\
 Number of characters in M-text.  int **mtext\_ref\_char** (**MText** \*mt, int pos)\
 Return the character at the specified position in an M-text.  int **mtext\_set\_char** (**MText** \*mt, int pos, int c)\
 Store a character into an M-text.  **MText** \* **mtext\_cat\_char** (**MText** \*mt, int c)\
 Append a character to an M-text.  **MText** \* **mtext\_dup** (**MText** \*mt)\
 Create a copy of an M-text.  **MText** \* **mtext\_cat** (**MText** \*mt1, **MText** \*mt2)\
 Append an M-text to another.  **MText** \* **mtext\_ncat** (**MText** \*mt1, **MText** \*mt2, int n)\
 Append a part of an M-text to another.  **MText** \* **mtext\_cpy** (**MText** \*mt1, **MText** \*mt2)\
 Copy an M-text to another.  **MText** \* **mtext\_ncpy** (**MText** \*mt1, **MText** \*mt2, int n)\
 Copy the first some characters in an M-text to another.  **MText** \* **mtext\_duplicate** (**MText** \*mt, int from, int to)\
 Create a new M-text from a part of an existing M-text.  **MText** \* **mtext\_copy** (**MText** \*mt1, int pos, **MText** \*mt2, int from, int to)\
 Copy characters in the specified range into an M-text.  int **mtext\_del** (**MText** \*mt, int from, int to)\
 Delete characters in the specified range destructively.  int **mtext\_ins** (**MText** \*mt1, int pos, **MText** \*mt2)\
 Insert an M-text into another M-text.  int **mtext\_insert** (**MText** \*mt1, int pos, **MText** \*mt2, int from, int to)\
 Insert sub-text of an M-text into another M-text.  int **mtext\_ins\_char** (**MText** \*mt, int pos, int c, int n)\
 Insert a character into an M-text.  int **mtext\_replace** (**MText** \*mt1, int from1, int to1, **MText** \*mt2, int from2, int to2)\
 Replace sub-text of M-text with another.  int **mtext\_character** (**MText** \*mt, int from, int to, int c)\
 Search a character in an M-text.  int **mtext\_chr** (**MText** \*mt, int c)\
 Return the position of the first occurrence of a character in an M-text.  int **mtext\_rchr** (**MText** \*mt, int c)\
 Return the position of the last occurrence of a character in an M-text.  int **mtext\_cmp** (**MText** \*mt1, **MText** \*mt2)\
 Compare two M-texts character-by-character.  int **mtext\_ncmp** (**MText** \*mt1, **MText** \*mt2, int n)\
 Compare initial parts of two M-texts character-by-character.  int **mtext\_compare** (**MText** \*mt1, int from1, int to1, **MText** \*mt2, int from2, int to2)\
 Compare specified regions of two M-texts.  int **mtext\_spn** (**MText** \*mt, **MText** \*accept)\
 Search an M-text for a set of characters.  int **mtext\_cspn** (**MText** \*mt, **MText** \*reject)\
 Search an M-text for the complement of a set of characters.  int **mtext\_pbrk** (**MText** \*mt, **MText** \*accept)\
 Search an M-text for any of a set of characters.  **MText** \* **mtext\_tok** (**MText** \*mt, **MText** \*delim, int \*pos)\
 Look for a token in an M-text.  int **mtext\_text** (**MText** \*mt1, int pos, **MText** \*mt2)\
 Locate an M-text in another.  int **mtext\_search** (**MText** \*mt1, int from, int to, **MText** \*mt2)\
 Locate an M-text in a specific range of another.  int **mtext\_casecmp** (**MText** \*mt1, **MText** \*mt2)\
 Compare two M-texts ignoring cases.  int **mtext\_ncasecmp** (**MText** \*mt1, **MText** \*mt2, int n)\
 Compare initial parts of two M-texts ignoring cases.  int **mtext\_case\_compare** (**MText** \*mt1, int from1, int to1, **MText** \*mt2, int from2, int to2)\
 Compare specified regions of two M-texts ignoring cases.  int **mtext\_lowercase** (**MText** \*mt)\
 Lowercase an M-text.  int **mtext\_titlecase** (**MText** \*mt)\
 Titlecase an M-text.  int **mtext\_uppercase** (**MText** \*mt)\
 Uppercase an M-text.

### Variables

MSymbol **Mlanguage**\

### Variables: Default Endian of UTF-16 and UTF-32

enum **MTextFormat** **MTEXT\_FORMAT\_UTF\_16**\
 Variable of value MTEXT\_FORMAT\_UTF\_16LE or MTEXT\_FORMAT\_UTF\_16BE.  const int **MTEXT\_FORMAT\_UTF\_32**\
 Variable of value MTEXT\_FORMAT\_UTF\_32LE or MTEXT\_FORMAT\_UTF\_32BE.

## Detailed Description

M-text objects and API for them.

In the m17n library, text is represented as an object called *M-text* rather than as a C-string (`char *` or `unsigned char *`). An M-text is a sequence of characters whose length is equals to or more than 0, and can be coined from various character sources, e.g. C-strings, files, character codes, etc.

M-texts are more useful than C-strings in the following points.

- •

  M-texts can handle mixture of characters of various scripts, including all Unicode characters and more. This is an indispensable facility when handling multilingual text.

- •

  Each character in an M-text can have properties called *text* *properties*. Text properties store various kinds of information attached to parts of an M-text to provide application programs with a unified view of those information. As rich information can be stored in M-texts in the form of text properties, functions in application programs can be simple.

In addition, the library provides many functions to manipulate an M-text just the same way as a C-string. \

## Enumeration Type Documentation

### enum MTextFormat

Enumeration for specifying the format of an M-text. The enum **MTextFormat** is used as an argument of the **mtext\_from\_data()** function to specify the format of data from which an M-text is created. \

**Enumerator**

- *MTEXT\_FORMAT\_US\_ASCII*

  *US-ASCII encoding*

- *MTEXT\_FORMAT\_UTF\_8*

  *UTF-8 encoding*

- *MTEXT\_FORMAT\_UTF\_16LE*

  *UTF-16LE encoding*

- *MTEXT\_FORMAT\_UTF\_16BE*

  *UTF-16BE encoding*

- *MTEXT\_FORMAT\_UTF\_32LE*

  *UTF-32LE encoding*

- *MTEXT\_FORMAT\_UTF\_32BE*

  *UTF-32BE encoding*

- *MTEXT\_FORMAT\_MAX*

  ### enum MTextLineBreakOption

*Enumeration for specifying a set of line breaking option. The enum* **MTextLineBreakOption** *is to control the line breaking algorithm of the function* **mtext\_line\_break()** *by specifying logical-or of the members in the arg option.* \

**Enumerator**

- *MTEXT\_LBO\_SP\_CM*

  *Specify the legacy support for space character as base for combining marks. See the section 8.3 of UAX#14.* \

- *MTEXT\_LBO\_KOREAN\_SP*

  *Specify to use space characters for line breaking Korean text.* \

- *MTEXT\_LBO\_AI\_AS\_ID*

  *Specify to treat characters of ambiguous line-breaking class as of ideographic line-breaking class.* \

- *MTEXT\_LBO\_MAX*

  ## Variable Documentation

### enum MTextFormat MTEXT\_FORMAT\_UTF\_16` [extern]`

*Variable of value MTEXT\_FORMAT\_UTF\_16LE or MTEXT\_FORMAT\_UTF\_16BE. The global variable* **MTEXT\_FORMAT\_UTF\_16** *is initialized to* **MTEXT\_FORMAT\_UTF\_16LE** *on a 'Little Endian' system (storing words with the least significant byte first), and to* **MTEXT\_FORMAT\_UTF\_16BE** *on a 'Big Endian' system (storing words with the most significant byte first).* \

**SEE ALSO**

**mtext\_from\_data()** \

### const int MTEXT\_FORMAT\_UTF\_32` [extern]`

Variable of value MTEXT\_FORMAT\_UTF\_32LE or MTEXT\_FORMAT\_UTF\_32BE. The global variable **MTEXT\_FORMAT\_UTF\_32** is initialized to **MTEXT\_FORMAT\_UTF\_32LE** on a 'Little Endian' system (storing words with the least significant byte first), and to **MTEXT\_FORMAT\_UTF\_32BE** on a 'Big Endian' system (storing words with the most significant byte first). \

**SEE ALSO**

**mtext\_from\_data()** \

### MSymbol Mlanguage

The symbol whose name is 'language'.

## Author

Generated automatically by Doxygen for The m17n Library from the source code.

## 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\>.
