⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 multibyte.3

📁 早期freebsd实现
💻 3
字号:
.\" Copyright (c) 1993.\"	The Regents of the University of California.  All rights reserved..\".\" This code is derived from software contributed to Berkeley by.\" Donn Seeley of BSDI..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\"    notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\"    notice, this list of conditions and the following disclaimer in the.\"    documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\"    must display the following acknowledgement:.\"	This product includes software developed by the University of.\"	California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\"    may be used to endorse or promote products derived from this software.\"    without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\"	@(#)multibyte.3	8.1 (Berkeley) 6/4/93.\".Dd "June 4, 1993".Dt MULTIBYTE 3.Os.Sh NAME.Nm mblen ,.Nm mbstowcs ,.Nm mbtowc ,.Nm wcstombs ,.Nm wctomb.Nd multibyte character support for C.Sh SYNOPSIS.Fd #include <stdlib.h>.Ft int.Fn mblen "const char *mbchar" "int nbytes".Ft size_t.Fn mbstowcs "wchar_t *wcstring" "const char *mbstring" "size_t nwchars".Ft int.Fn mbtowc "wchar_t *wcharp" "const char *mbchar" "size_t nbytes".Ft size_t.Fn wcstombs "char *mbstring" "const wchar_t *wcstring" "size_t nbytes".Ft int.Fn wctomb "char *mbchar" "wchar_t wchar".Sh DESCRIPTIONThe basic elements of some written natural languages such as Chinesecannot be represented uniquely with single C.Va char Ns s .The C standard supports two different ways of dealing withextended natural language encodings,.Em widecharacters and.Em multibytecharacters.Wide characters are an internal representationwhich allows each basic element to mapto a single object of type.Va wchar_t .Multibyte characters are used for input and outputand code each basic element as a sequence of C.Va char Ns s .Individual basic elements may map into one or more.Pq up to Dv MB_CHAR_MAXbytes in a multibyte character..PpThe current locale.Pq Xr setlocale 3governs the interpretation of wide and multibyte characters.The locale category.Dv LC_CTYPEspecifically controls this interpretation.The.Va wchar_ttype is wide enough to hold the largest valuein the wide character representations for all locales..PpMultibyte strings may contain.Sq shiftindicators to switch to and fromparticular modes within the given representation.If explicit bytes are used to signal shifting,these are not recognized as separate charactersbut are lumped with a neighboring character.There is always a distinguished.Sq initialshift state.The.Fn mbstowcsand.Fn wcstombsfunctions assume that multibyte strings are interpretedstarting from the initial shift state.The.Fn mblen ,.Fn mbtowcand.Fn wctombfunctions maintain static shift state internally.A call with a null.Fa mbcharpointer returns nonzero if the current locale requires shift states,zero otherwise;if shift states are required, the shift state is reset to the initial state.The internal shift states are undefined after a call to.Fn setlocalewith the.Dv LC_CTYPEor.Dv LC_ALLcategories..PpFor convenience in processing,the wide character with value 0.Pq the null wide characteris recognized as the wide character string terminator,and the character with value 0.Pq the null byteis recognized as the multibyte character string terminator.Null bytes are not permitted within multibyte characters..PpThe.Fn mblenfunction computes the length in bytesof a multibyte character.Fa mbchar .Up to.Fa nbytesbytes are examined..PpThe.Fn mbtowcfunction converts a multibyte character.Fa mbcharinto a wide character and stores the resultin the object pointed to by.Fa wcharp.Up to.Fa nbytesbytes are examined..PpThe.Fn wctombfunction converts a wide character.Fa wcharinto a multibyte character and storesthe result in.Fa mbchar .The object pointed to by.Fa mbcharmust be large enough to accommodate the multibyte character.  .PpThe.Fn mbstowcsfunction converts a multibyte character string.Fa mbstringinto a wide character string.Fa wcstring .No more than.Fa nwcharswide characters are stored.A terminating null wide character is appended if there is room..PpThe.Fn wcstombsfunction converts a wide character string.Fa wcstringinto a multibyte character string.Fa mbstring .Up to.Fa nbytesbytes are stored in.Fa mbstring .Partial multibyte characters at the end of the string are not stored.The multibyte character string is null terminated if there is room..Sh "RETURN VALUESIf multibyte characters are not supported in the current locale,all of these functions will return \-1 if characters can be processed,otherwise 0..PpIf.Fa mbcharis.Dv NULL ,the.Fn mblen ,.Fn mbtowcand.Fn wctombfunctions return nonzero if shift states are supported,zero otherwise.If.Fa mbcharis valid,then these functions returnthe number of bytes processed in.Fa mbchar ,or \-1 if no multibyte charactercould be recognized or converted..PpThe.Fn mbstowcsfunction returns the number of wide characters converted,not counting any terminating null wide character.The.Fn wcstombsfunction returns the number of bytes converted,not counting any terminating null byte.If any invalid multibyte characters are encountered,both functions return \-1..Sh "SEE ALSO.Xr euc 4 ,.Xr mbrune 3 ,.Xr rune 3 ,.Xr setlocale 3 ,.Xr utf2 4.Sh STANDARDSThe.Fn mblen ,.Fn mbstowcs ,.Fn mbtowc ,.Fn wcstombsand.Fn wctombfunctions conform to.St -ansiC ..Sh BUGSThe current implementation does not support shift states.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -